OK, i've tried everything (including several hours of reading and trying a lot of stuff on stackoverflow)
I'm trying to launch the default sms app from the android launcher, and using this code:
Intent smsIntent = new Intent(Intent.ACTION_MAIN);
smsIntent.addCategory(Intent.CATEGORY_DEFAULT);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(smsIntent);
break;
It works great on all phones BUT my NEXUS 5 .
Guess it has something to do with KITKAT, but not sure how to fix it..
Important - Im not trying to send the text or get it from the user (as i've seen people do here), just getting the user to the main screen of the sms app (hangouts in my case).
Thanks. :)
Intent intent = new Intent();
ComponentName cm =new ComponentName("com.google.android.talk","com.google.android.talk.SigningInActivity");
intent.setComponent(cm);
this adapter nexus, I get the ComponentName by ADB log.
Related
I have compileSdkVersion and targetSdkVersion 23 and testing on Samsung galaxy s3. But whenever i open any third party app (explicit intent) like camera/gallery app or share intent (gmail, email) or dialer app and comeback to my app by pressing back button or (in case of camera/gallery app by selecting picture). App restarts from MainAcitivty (maybe it is getting crashed but it does not show any exception in logcat). Here is how i open intents:
Call/Dial:
Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.parse("tel:" + phone));
context.startActivity(callIntent);
Gallery:
Intent intent = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, GALLERY_PIC_REQUEST);
Share:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
context.startActivity(Intent.createChooser(intent, dialogHeaderText));
This issue is only coming in Samsung s3. I have tested all above functionalities on Google nexus 5, Huawei Honor 4C and Samsung galaxy s5 it is working fine. Any help?
Every mentioned intent should have a callback mechanism, it is really strange in Samsung S3's case where I have to face it. I have searched a lot but didn't find anything.
Somehow, I have seen an option in Developer Options titled as Do not keet activities which destroys every activity of user as soon as possible when checked. Please make sure that it is unchecked.
I have fixed it for Samsung S3 with Android version 4.3 and found that this option in many devices and Android OS versions
Please follow these steps:
Android version 4.3 (Samsung galaxy S3):
Go to Settings >> More (Tab) >> Developer Options >>
Do not keep activities
Make sure this option is unchecked
General:
Go to Settings >> Developer Options >> Do not keep
activities
Make sure this option is unchecked
Hope it will work :)
I see many people have asked about this problem like here, here and ... but I can not find any solution.
However, I see some background app on playstore can do it.
My purpose is that I want to open intent for set lock screen wallpager like
This device is SamSung S2
Generally there is no (proper) documentation on how to set the Lock screen Wallpaper. Samsung doesn't allow it as far it goes.
In some Phones, we are able to see the Wallpaper we set through Wallpaper Manager purely dependent on the Device Stock OS. And we have no control over it specifically.
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setDataAndType(Uri.parse(mPath), "image/jpeg");
intent.putExtra("mimeType", "image/jpeg");
startActivity(Intent.createChooser(intent, "Set as: Home Screen"));
I have been using below code to start an Intentin Android to send an email. Prior to Android Lollipop (API level 21) this worked fine. Unfortunately, in Android Lollipop, this throws an "Unsupported Action" error.
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("message/rfc822");
intent.setData(Uri.parse("mailto:" + email));
startActivity(intent);
It's pretty basic, it simply passes the e-mailaddress and lets the user pick which application to use.
How should I adapt my code to make this work across api levels? My minimum API level is 16 (JellyBean).
Edit
I've included the MIME-type, as per the comments and answers.
I've got it. This was caused by not having set up an emailaccount. After setting one up in at least one email app, it works.
It's not a problem with Lollipop.
You have to add intent.setType("message/rfc822"); see this detailed answer: How can I send emails from my Android application?
From my testing, this is a problem that happens when the intent's URI (from setData()) doesn't match anything and you're running on one of the official Android emulators. This doesn't seem to happen on real devices, so it shouldn't be a real-world problem.
You can use this code to detect when this is going to happen before you launch the intent:
ComponentName emailApp = intent.resolveActivity(getPackageManager());
ComponentName unsupportedAction = ComponentName.unflattenFromString("com.android.fallback/.Fallback");
boolean hasEmailApp = emailApp != null && !emailApp.equals(unsupportedAction);
(The name of the activity that shows the "Unsupported action" action method is com.android.fallback.FallbackActivity.)
By default this intent will be consumed by Android beam, I don't expect this behavior so I believe there must be something wrong in Lollipop.
I have a list in my application that shows the running apps and also i want to show used ram by the running application . (other apps)
also i don't want to use this code :
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setClassName("com.android.settings", "com.android.settings.RunningServices");
please give me a solution . thank you!
I have a program that I have made for Android 1.6 and up and I have been doing tests to ensure that the program works fine with the new Ice Cream Sandwich (Android 4).
Everything on the app works fine except that when a certain task has been performed by the user it is supposed to automatically launch the android browser. However for some reason it seems to load it up in the background and keeps my app shown which is not what I want it to do.
On every other version of android when I execute the code to launch the browser the browser comes to the top of the screen therefore causing my app to be in the background which is how I wanted it to work.
Below is the code that I have to launch the browser
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse(companyURL));
startActivity(intent);
The companyURL is a variable that I am using to parse the url to the browser.
Thanks for any help you can provide.
UPDATE
I have just discovered that if the browser is not currently running (i.e. not been loaded previously) when my app starts the browser it brings it to the front. However, once the browser has been previously loaded, when my app loads it up again, it loads it in the background.
Please try this it is working on ICS for me.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(companyURL));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Typically you don't need the CATEGORY_BROWSABLE category. Try the following instead:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(companyURL));
startActivity(intent);
In fact, the documentation seems to suggest CATEGORY_BROWSABLE is intended to be used in the opposite direction (browser to your app):
Activities that can be safely invoked from a browser must support this category. For example, if the user is viewing a web page or an e-mail and clicks on a link in the text, the Intent generated execute that link will require the BROWSABLE category, so that only activities supporting this category will be considered as possible actions.
http://developer.android.com/reference/android/content/Intent.html#CATEGORY_BROWSABLE
Try adding FLAG_ACTIVITY_BROUGHT_TO_FRONT flag to the intent.
I'm using following code and its working fine with me even when browser is already running in the background.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(intent);