Interaction with Market app is causing window focus errors - android

I have a strange problem, I am wanting to launch to the marketplace from my app - am doing the following.
Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
"market://details?id=" + activity.getPackageName()));
try {
activity.startActivity(marketIntent);
} catch (ActivityNotFoundException e) {
Toast.makeText(activity, "Could not launch market", Toast.LENGTH_LONG).show();
}
However when there the user can press Open again, when they do that I get :
08-22 15:18:37.510: INFO/ActivityManager(260): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.xyz.appname cmp=com.xyz.appname/.mainapp } from pid 22853
08-22 15:18:37.590: INFO/ActivityManager(260): Starting: Intent { cmp=com.xyz.appname/.secondactivity } from pid 25735
08-22 15:18:37.590: WARN/InputManagerService(260): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#2b49a938
and it never reopens the app , they just stuck there - hitting back does work.
Tracing the code the warning is coming from this in mainapp :
Intent tabActivity = new Intent();
tabActivity.setClass(this, secondactivity.class);
startActivity(tabActivity);
this.finish();

This definitely looks like an issue with how it is restarted - you're on the right track with that last bit of code.
This flag looks like what you need to tell Android to pull the existing activity off of the history stack and re-use it:
FLAG_ACTIVITY_SINGLE_TOP
Alternatively (if you want to restart rather than resume), maybe you could hint to Android to recycle the activity after you move on, by using this with your intent:
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

Related

Launching An External Shortcut

I'm trying to launch an external shortcut, What i have is only the activity path .
Here's what i did :
try {
view.getContext().startActivity(Intent.getIntentOld(List.getShortcutPath());
} catch (URISyntaxException e) {
e.printStackTrace();
}
Log :
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=com.sonyericsson.music.ArtistShortcutActivity }
The Path I'm trying to launch :
com.sonyericsson.music.ArtistShortcutActivity
How to launch the shortcut ?
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.example", "com.example.MyExampleActivity"));
startActivity(intent);
if you get permission denial error, then add android:exported XML attribute is true in the manifest for the activity you want to launch
Here com.example is the package name of the app your activity that you want to launch is in, and com.example.myexampleactivity the full name of the activity you want to launch
If the intended activity to launch is package private, then you wont be able to launch it from a foreign application activity. This is done for security reasons by Google

calling VoiceListActivity of Voice Recorder

I am trying to call VoiceListActivity of VoiceRecorder from my app on samsung S4 but I get following error
08-27 09:35:03.401: E/AndroidRuntime(17313): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.RUN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.sec.android.app.voicerecorder/.VoiceListActivity } from ProcessRecord{449e11c8 17313:com.example.ui_sha/u0a205} (pid=17313, uid=10205) not exported from uid 10193
my code :
Intent intent = new Intent(Intent.ACTION_RUN);
intent.setComponent(ComponentName.unflattenFromString("com.sec.android.app.voicerecorder/com.sec.android.app.voicerecorder.VoiceListActivity"));
intent.addCategory("android.intent.category.LAUNCHER");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
So my question is :
Can i use Intent to call VoiceListActivity from my app? If yes, How I have to do ?
If no, can you show me another way to call it ?
Solution :
I asked some body to solve this problem but it is impossible when code in VoiceList's manifest have android:exported = true. So the only solution is you need to build your own VoiceListActivity and its screen. It could be take some time but it is only solution.

Open Intent in a new context

When I open a link inside the Facebook app, it opens a new task for the browser while I can switch back to the Facebook app instead of opening the browser inside itself like an ordinary Activity. But when I launch an Intent to my application's Google Play page it behaves like an Activity inside my app instead of launching a separate instance for Google Play.
Here's how I'm starting the Intent:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=MY.APP.PACKAGE")));
I found this thread and wrote this snippet:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("market://details?id=MY.APP.PACKAGE"));
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
Which fails with this message in logcat:
04-29 12:35:42.681: E/AndroidRuntime(8482): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW cat=[android.intent.category.LAUNCHER] dat=market://details?id=MY.APP.PACKAGE flg=0x50000000 }
Any ideas?
You just need to remove the addCategory() call and it should work.

Opening my application from Google Play App crashes on exit

I have option to open my app Google Play page inside my app. When clicking open button in Google Play My app launches again. (From Splash screen)
When I am exiting my app it crashed. I tried put singleTask flag to my Home activity. It actually worked fine. But arised another crash. So I need to know is:
Is there any option to put flag in my Market calling Intent to notify that the app is already launched and just bring it front on clicking Open button?
Here how am I calling GooglePlay app.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(marketUrl));
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, "Cannot find Android Market",
Toast.LENGTH_LONG).show();
}
EDIT
My market url: market://details?id=com.foo.bar
This will directly redirect to my apps Installation page.
use this code..
Uri uri = Uri.parse(https://play.google.com/store);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

Starting an external activity, getting permission error

I'm trying to start the preferences activity in the native messenger client from my application. in AOSP Mms.apk does not have an intent filter setup on that activity. Regardless I'm trying to find a work around to launch the user into that screen.
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(ComponentName.unflattenFromString("com.android.mms/com.android.mms.ui.MessagingPreferenceActivity"));
intent.addCategory("android.intent.category.LAUNCHER");
try {
startActivity(intent);
} catch (Exception e) {
AppUtils.alertError(this, error);
}
I'm receiving
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.android.mms/.ui.MessagingPreferenceActivity } from ProcessRecord{406e2738 674:com.handmark.genericapp/10034} (pid=674, uid=10034) requires null
Any thoughts?
What you want is not possible. That activity is not exported (at least in the source code showing in Google Code Search), so you cannot start it, except by rewriting the app as part of your own custom firmware.
Also, bear in mind that this app may or may not exist on any given device.

Categories

Resources