Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.putExtra("address", "12134567899");
intent.putExtra("sms_body", "See attached picture");
intent.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file:///sdcard/DCIM/Camera/2011-09-09 12.47.29.jpg"));
intent.setType("image/png");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
i try code like this. if intent start mms compose ui was coming how can i overcome and send automatically
First of all. good luck.
Since MMS isn't supported by the android sdk, you have 2 options:
download the android mms aplication and try to understand what's going on there.
follow this link:
http://androidbridge.blogspot.com/2011/03/how-to-send-mms-programmatically-in.html
only thing I found working at the moment....
This feature was designed as a safety feature in Android, please do not try to bypass it. It's there for a reason.
If you absolutly must, have you tried running it on a rooted device? It allows greater access.
try this its worked with me .
use
Uri.fromFile
instead of
Uri.parse
File f=new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/DCIM/Camera/"+img_name);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("", "");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
sendIntent.setType("image/png");
startActivity(sendIntent);
Related
I'm about to launch my first app in a week,and want to know if google play automatically adds the shortcut to the home-screen or is it something if have to do with code. I have question like this but there's nothing about creating shortcut on install.
I launched my app found that Google Play does automatically creates a shortcut on the homescreen and we don't have to do it in our code,although i don't know if it works the same way in Amazon app store. hope this helps someone who is trying to find answer to the same question.
Mohit Madaan's answer was correct. Just don't forget to set duplicate to false otherwise you might have several shortcuts:
addIntent.putExtra("duplicate", false);
put this permission in manifest
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
below for creating the shortcut icon on android Homescreen
private void ShortcutIcon(){
Intent shortcutIntent = new Intent(getApplicationContext(), MainActivity.class);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Test");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.ic_launcher));
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);}
I came across this and I hope this helps you. http://viralpatel.net/blogs/android-install-uninstall-shortcut-example/
I used the following code to launch PackageInstallerActivity
ComponentName comp = new ComponentName("com.android.packageinstaller", "com.android.packageinstaller.PackageInstallerActivity");
Intent newIntent = new Intent(Intent.ACTION_VIEW);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
newIntent.setComponent(comp);
But in Marshmallow, that's not working.
I found the answer, use Intent.ACTION_INSTALL_PACKAGE instead of Intent.ACTION_VIEW.
But, why does Intent.ACTION_VIEW not work?
Look this link Android Document REQUEST_INSTALL_PACKAGES, If your app is targeting API level higher than 25 you need to hold REQUEST_INSTALL_PACKAGES in order to launch the application installer.
I want to create a sharing button via some applications only.
right now I`m using this code:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "App Name");
intent.putExtra(Intent.EXTRA_TEXT, "Check out this cool app http://market.android.com/details?id=com.example.yourpackagename");
Intent chooser = Intent.createChooser(intent, "Tell a friend about App Name");
startActivity(chooser);
But it opens a huge window with all the apps installed at the device. I want to show only chosen options (Facebook, Whatsapp, Gmail).
Thank you.
Have a look at this answer, I would suggest going with it : https://stackoverflow.com/a/9755553/1542720
Some other workarounds/solutions :
http://hkdevtips.blogspot.in/2013/02/customize-your-actionchooser-intent.html
Custom filtering of intent chooser based on installed Android package name
i am developing an android app where i want to open the Battery use intent which is present in About device part of settings programatically. I am using the below code for it.
Intent i = new Intent();
i.setAction(android.provider.Settings.ACTION_DEVICE_INFO_SETTINGS);
startActivity(i);
The above code opens the About Device intent. But i want to open the Battery use option which is inside the About device part of Settings. Not getting how to do it. Please Help! Thanks!
Intent intentBatteryUsage = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
startActivity(intentBatteryUsage);
Try this..
Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
ResolveInfo resolveInfo = getPackageManager().resolveActivity(powerUsageIntent, 0);
if(resolveInfo != null){
startActivity(powerUsageIntent);
}
I am currently in the process of creating direct intents to a selection of popular platforms in an Android app to share some text. I am currently trying to get a direct intent working with LinkedIn.
I have currently got a direct intent working for Twitter like so:
shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setClassName("com.twitter.android",
"com.twitter.android.PostActivity");
shareIntent.setType("text/*");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);
startActivityForResult(shareIntent, 9);
What I need now is the same for LinkedIn. So far I know the base package for LinkedIn after searching on the internet. That being "com.linkedin.android" (Please correct me if this is wrong). However, the key part I am missing is the name of the class that deals with sharing in the LinkedIn app. I.e. com.linkedin.android.?.
I managed to find the intent by extracting the LinkedIn Manifest file from the APK.
The class name is: com.linkedin.android.home.UpdateStatusActivity
My code for anyone interested is:
if(Utils.doesPackageExist(getSherlockActivity(), "com.linkedin.android"))
{
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setClassName("com.linkedin.android",
"com.linkedin.android.home.UpdateStatusActivity");
shareIntent.setType("text/*");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareText);
startActivity(shareIntent);
}
else
{
Toast.makeText(getSherlockActivity(), "Please install the LinkedIn app to share your result", Toast.LENGTH_LONG).show();
}
Credit to Ryszard Wiśniewski for his work on http://code.google.com/p/android-apktool/
As of my writing, the new class name is:
com.linkedin.android.infra.deeplink.DeepLinkHelperActivity
So all together:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setClassName("com.linkedin.android",
"com.linkedin.android.infra.deeplink.DeepLinkHelperActivity");
shareIntent.setType("text/*");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareText);
startActivity(shareIntent);
It is com.linkedin.android.publishing.sharing.ShareActivity , you can download this app and see what is the current Activity name thats running on your phone https://play.google.com/store/apps/details?id=com.willme.topactivity ... But com.linkedin.android.publishing.sharing.ShareActivity seems its a private class and you can't access as you access Twitter