How to set Intent result in Layout - android

friend's,
I there any possibility to bind the result of Intent class in xml layout,
i'm doing it so for sending mail,i'm using below code for sending mail in
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
sendIntent.putExtra(Intent.EXTRA_EMAIL,
new String[] { "info#blacksheep.com" });
sendIntent.setType("vnd.android.cursor.dir/email");
when i use the above code it opens a new page,but i need it to be in the layout alone.
How can i get it.
Thanks in advance.

when i use the above code it opens a new page,but i need it to be in the layout alone. How can i get it.
You cannot do that, sorry. You are opening an activity from another application (whatever the user chooses to handle your ACTION_SEND request) -- it controls the presentation, not you.

Related

How to add a share button inside a view in Android?

I need to add a share button to one view inside one of my DialogFragments (Not in the action bar).
Can you give me a clue or a sample maybe? All I could find googling is for action bar (like Sherlok) which is not what I'm looking for.
Step #1: Put a button inside of your DialogFragment.
Step #2: When the user clicks the button, create an ACTION_SEND Intent to share whatever it is you want to share, and call startActivity() on it (or, if desired, wrap the Intent you create in a chooser Intent via Intent.createChooser()):
void sendIt(String theMessage) {
Intent i=new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_SUBJECT, R.string.share_subject);
i.putExtra(Intent.EXTRA_TEXT, theMessage);
startActivity(Intent.createChooser(i,
getString(R.string.share_title)));
}

Make Intent.ACTION_VIEW accept multiple URIs

I want to launch some apps which accept geo coordinates (http://developer.android.com/training/sharing/send.html). The problem is that they want different URIs.
Example (pseudo code):
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
intent.addSomeUri("http://maps.google.com/maps/?daddr="+myAddress);
intent.addSomeUri("http://someotherservice.com/?coordinates="+myLat+":"+myLng+"&address=myAddress");
EDIT:
Of course the goal is for both apps to appear in the same activity chooser.
How can I achieve it?
How can I achieve it?
Call startActivity() (or startService() or whatever) once per Uri.
Do you really want to launch every app?
If not, you have simpler way
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("geo:30.0, 120.0"));
startActivity(intent);

What is createChooser when I have to use Intents? What I could do with this method?

I have been taking a look over stackoverflow but I did't find a definition about what is "createChooser" and why I can use and in whick kind of situations is good to use it.
Thanks in advance.
For example: you have a share picture option in your application.
You define an intent like this:
Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND);
picMessageIntent.setType("image/jpeg");
File downloadedPic = new File(
Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS),
"q.jpeg");
picMessageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));
Than when you call:
startActivity(picMessageIntent);
all applications on your phone capable of getting this picture will be listed.
If you want to custimize the title of that list, you can use createChooser like this:
startActivity(Intent.createChooser(picMessageIntent, "Send your picture using:"));
When startActivity(intent) is called for the first time from your app the user sees a list of all apps capable to handle this intent.
There is also an option to always handle this intent using one of the apps from the list. If this option is used then the list will never be shown again.
If you use createChooser in your intent then the "always use this app" option is not shown. The user always sees this list.
This method is used when you want to create a Custom Action using an Intent... Just like what android provides ACTION_VIEW etc... but here when there are multiple choices to perform an an Action this chooser will bring up a dialog which will have all available options and let the user select one... here is an example

Android MMS code specific?

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("address","5554);
sendIntent.putExtra("sms_body", "some text");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
sendIntent.setType("image/png");
I have already given the receiver number programatically. Now I wanted only the "Send MMS" button event here. So can I handle it in code itself? My aim is disabling UI in this context. Is this achievable?
Is there anyway for attaching image without using intent??
Plz help.
Using "Intent.ACTION_SEND" will launch SMS/MMS applications. I think that is not what you want.
MMS is a http post request. You have to implement in another way.
you will need to create member of type Activity which should injected in this class as constructor method or setter and within that context if you try your function it might solve.i have successfully send sms by this way.

Accessing Android Inbox/Messaging from Activity?

Is it possible to open up the default Android Messaging activity from inside an activity you write yourself? Like for example: I press a "Mail" button inside my program, and it opens the Android Messaging app just like as if I was to press the Messaging icon on the main screen.
I did something similar to this with the Contacts activity, but only the contact list comes up, no extra functionality like Adding/Modifying/Deleting, etc.
Any ideas?
edit: I found this way to open the "Compose New Message" Activity, I just need to back it up a step. Does anyone know the correct MIME type instead of this one?
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setType("vnd.android-dir/mms-sms");
m_activity.startActivity(sendIntent);
This starts the messaging app from another app:
Intent intent = new Intent("android.intent.action.MAIN");
intent.setComponent(new ComponentName("com.android.mms","com.android.mms.ui.ConversationList"));
startActivity(intent);
Just put it inside a button listener or whatever user input you want to open it from.
Enjoy :-)
If you want to open the messaging app to view messages and not for sending a message, this should do the job:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setPackage("com.google.android.apps.messaging");
startActivity(intent);

Categories

Resources