theblitz
theblitz

Reputation: 6881

Implicit intent within same application

How do I build an intent and the Manifest so that I can invoke an activity with my application as an implicit intent.

The idea is that I am writing some general code that I wish to use in a number of applications. This code is held in an Android library and is linked to the using application. This general code opens an activity and does some work. Once it is done (user clicks a button) it needs to transfer to an activity that is specific to this application.

Upvotes: 2

Views: 2565

Answers (2)

user370305
user370305

Reputation: 109237

As per my understanding on your questions,

You can declare your activity with specified implicit intent in your application's manifest file..

For example: If you want to make a application for view Image with your application and you have to use that application on your device which can allow other activity to view image using implicit intent action.VIEW so ,just

 <activity android:label="@string/app_name" android:name=".MyImageViewerActivity">  
            <intent-filter>  
                <action android:name="android.intent.action.MAIN">  

                <category android:name="android.intent.category.LAUNCHER">  
            </category></action></intent-filter>  
            <intent-filter>  
                <action android:name="android.intent.action.VIEW">  

                <category android:name="android.intent.category.DEFAULT">  

                <data android:mimetype="image/*">  
            </data></category></action></intent-filter>  
</activity>  

In the above code we can see that intent-filter has following properties.

a. action: type for which this activity will respond for.Like this activity will respond for view action.

b. category: implicit intents are divided in categories.Like this activity is in default category.

c. data: Specify more information about intent-filter. Like this activity will handle file of mimeType “image/*”.

And when you install this application in your device and click on any image file, you will see a choice dialog that offer you to select between default application and your application. Just select your application to see the image.

For more info with example look at this What is intent filter in android?

Tutorial: Registering via Intentfilter

Upvotes: 1

Dmitry Zaytsev
Dmitry Zaytsev

Reputation: 23962

I think you can use intent-filters. I didn't use it for such things, but I hope that will help you.

Idea is that you can call your activity not by name, but by it's action (that is setted in intent-filter in your Manifest)

Upvotes: 0

Related Questions