custom Activities in the chooser intent??

SoundCloud clone for Android and Web
Lollipop
Posts: 61
Joined: Thu Aug 27, 2015 7:29 am

custom Activities in the chooser intent??

Postby Lollipop » Sat Aug 29, 2015 8:48 am

Hi,
I want to Add the custom Activities like one activity to take camera picture and one activity to choose photo from gallery to one chooser intent as action of these two intents are different how can i call this in single chooser intent?? How can i do this??

sagar
Posts: 37
Joined: Mon Aug 24, 2015 11:23 am

Re: custom Activities in the chooser intent??

Postby sagar » Sat Aug 29, 2015 9:03 am

Hi,

you can write separate activities to do the functionality like one activity to take the picture from camera and one activity to choose the photo from Gallery, and you need add the same action in the intent filter of all these activity in the manifest.

ex:

Code: Select all

  <activity
            android:name=".Camara"
            android:icon="@drawable/camera"
            android:label="Camera" >
            <intent-filter>
                <action android:name="android.intent.action.setProfile" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="text/plain" />
            </intent-filter>
            </activity>
           
 <activity
            android:name=".Gallery"
            android:icon="@drawable/gallary"
            android:label="Gallery" >
            <intent-filter>
                <action android:name="android.intent.action.setProfile" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="text/plain" />
                <data android:mimeType="image/*" />
            </intent-filter>
            </activity>

       


In the above code i have registered two activities in the manifest one is camera activity which is used to take the camera picture and Gallery activity is used to choose the image from gallery and these two activities are having the same action in the intent filter "android.intent.action.setProfile".

Two call these two activities in the chooser intent use the following code,

Code: Select all

 
  String message = "Text I want to share";
                Intent share = new Intent("android.intent.action.setProfile");
                share.setType("text/plain");
                share.putExtra(Intent.EXTRA_TEXT, message);
                startActivityForResult(Intent.createChooser(share, "Profile Photo"), 100);
               


Here in the above code i am calling the chooser intent with the intent filter "android.intent.action.setProfile" which is specified for Camera and Gallery activities so these two activities will be listed once you start the chooser intent.

Lollipop
Posts: 61
Joined: Thu Aug 27, 2015 7:29 am

Re: custom Activities in the chooser intent??

Postby Lollipop » Mon Aug 31, 2015 11:36 am

Perfect. Will let you know after trying.


Return to “SoundStar”

Who is online

Users browsing this forum: No registered users and 2 guests