I am trying to use android.provider.Telephony.Mms.* items. However it isn't in the sdk. How do you about linking against those classes?
I can probably do it using this method:
Where is com.google.android.mms.*?
Class pduparserclass = Class.forName("android.provider.Telephony.Mms.");
Mms and other apps use private or hidden APIs that are not available through the SDK. Third party apps can't use the private API for various reasons, one being security.
If you want to modify and build MMS you have to create your own ROM so you have to interact with the firmware build.
You can send an SMS/MMS via an itent with this code:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "some text");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
sendIntent.setType("image/png");
Related
the email app is not opening on my android device. there are no error in code but don't know why app isn't working
You are using an old or deprecated way to start activity for ACTION_SEND scenarios. Use below snippet for the correct way.
val sendIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, "This is my text to send.")
type = "text/plain"
}
val shareIntent = Intent.createChooser(sendIntent, null)
startActivity(shareIntent)
You can check out the code snippet and detailed explanation here.
https://developer.android.com/training/sharing/send#using-android-system-sharesheet
Starting with API level 30, if you're targeting that version or higher, your app cannot see, or directly interact with, most external packages without explicitly requesting allowance.
Check this answer, it works for me.
https://stackoverflow.com/a/65166064/7248394
When a user clicks a button in my app, it's supposed to launch an SMS app. To to this, I simply fired an intent.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", "+234000000000", null));
intent.putExtra("sms_body", "Hello!"));
if (intent.resolveActivity(getActivity().getPackageManager()) != null) startActivity(intent);
This works perfectly fine! The only problem is that Facebook Messenger is among the list of apps that show up and I don't want that.
How can I filter this list and remove specific apps like Messenger?
Yes, you can restrict your app to open just android default messaging app.
Uri uri = Uri.parse("sms:+444498494984");
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
//android sms app package name
intent.setPackage("com.google.android.apps.messaging");
intent.putExtra("sms_body", "message to send");
if (intent.resolveActivity(getPackageManager()) != null)
{
startActivity(intent);
}
It is trying to give the user a choice on their favourite SMS app, Don't forget that Facebook Messenger can also manage SMS now that is why it is showing up as a choice. In my experience, Unless the user selects 'always' it can't be avoided. Imagine if the user has other apps to manage SMS we can't force them to use our preferred messaging app.
I have created an kiosk application it has update functionality for other application within the device but the installer package is blocked. How to whitelist installer package?
I have tried whitelisting this installer package but it is not working. Maybe I'm missing an additional application to whitelist.
...//My other whitelisted apps
private static String INSTALLER_PACKAGE = "com.google.android.packageInstaller";
private static String[] APP_PACKAGES = { ..., INSTALLER_PACKAGE};
...
dpm.setLockTaskPackages(cn, active ? APP_PACKAGES : new String[]{});
If you are setting FLAG_ACTIVITY_NEW_TASK flag on the ACTION_INSTALL_PACKAGE intent it will generally tell you "Unpinning is not allowed" when trying to invoke the PackageInstaller to update.
For instance, in this example (AppCenter)
Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
intent.setData(fileUri);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // <-- giving me grief
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
I have found through my investigations that HockeyApp, Microsoft AppCenter and TestFairy is setting this flag, so I was unable to use their out-of-the-box in-app update solution when pinned (task locked). I'm also running android:launchMode="singleTask" for what it's worth.
I was however able to change HockeyApp's library to my liking. This was my initial inquiry https://github.com/bitstadium/HockeySDK-Android/issues/368
I am trying to share link with my android app with this:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, share);
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "");
mContext.startActivity(intent);
this is the share Strong :
Check out my link:\n http://my123domain.com/v.php?vid=123456-123456-123456
But when i share it with Whats App the link is not click able,
Any idea Why?
Whatsapp does not allow sending clickable text links to people who do not have you in their contact list. Make sure receiving party have you in their contact list.
I have an application that allows the user to send a picture. This picture can be sent via a number of different ways, like g-mail, facebook, flickr, and the one I am interested in, text messaging. When the following code is run, a dialog box pops up with a number of these options available.
Uri uri = Uri.fromFile(new File(externalDirectory + FILE_DIRECTORY + fileName));
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType("image/png");
startActivity(intent);
On my Droid X, the text messaging option is shown, and this code adds the picture to the MMS perfectly.
On the emulator, text messaging is chosen automatically (since there are no other options) and once again it works great.
On my Droid Incredible, there is no text messaging option. However, I can manually bring up the built-in text messaging utility, add the picture and then send it. I also downloaded an SMS/MMS app from the market, and afterward the option to use this 3rd party program to send the picture was available from the list.
So, why isn't text messaging an available option on the Droid Incredible? What do I need to do to make it an option, and how do I evaluate this problem (OR UNKNOWN PROBLEMS) with phone types I have no access to?
So, why isn't text messaging an available option on the Droid Incredible?
Because they chose not to offer it.
What do I need to do to make it an option
In the abstract, you can't.
Quoting the Android Compatibility Definition Document:
The Android upstream project defines a number of core applications, such as a phone dialer, calendar, contacts book, music player, and so on. Device
implementers MAY replace these applications with alternative versions.
However, any such alternative versions MUST honor the same Intent patterns provided by the upstream project. For example, if a device contains an
alternative music player, it must still honor the Intent pattern issued by third-party applications to pick a song.
The catch is, the Messenger app is not considered a "core application" by Google. Hence, device manufacturers are welcome to include their own SMS clients, with their own Intent filters. In the case of the HTC Incredible, apparently they did not include support for MMS via an image/png ACTION_SEND Intent.
Now, IMHO, Messenger probably should be a core application. However, your opinion and mine do not change reality as it stands today.
how do I evaluate this problem (OR UNKNOWN PROBLEMS) with phone types I have no access to
You redefine your application such that it is not a "problem". You have no guarantee that you can send an MMS that way, just as you have no guarantee that a user has a Facebook app installed.
I don't know much about MMS and am uncertain if there is a way other than ACTION_SEND to send an MMS. You might consider poking through the source code to the Messenger app to see how it does it. Then, bake the capability directly into your app. This will require a few extra permissions (SEND_SMS, and probably READ_CONTACTS) and will be annoying to write, but it will be more likely to work across devices.
I did manage to come up with a work around for this, thanks to some help from some other questions on SO.
Basically the key was determining the intent used by HTC, which appears to be the only company (currently) that's modified the android.intent.action.SEND Intent. Here is the code to add the option to the list.
Uri uri = Uri.fromFile(new File(mFile));
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType("image/png");
Intent htcIntent = new Intent("android.intent.action.SEND_MSG");
htcIntent.setType("image/png");
htcIntent.putExtra(Intent.EXTRA_STREAM, uri);
Intent chooser = Intent.createChooser(intent, "Send Method");
chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { htcIntent });
startActivity(chooser);