Beruflich Dokumente
Kultur Dokumente
Stack Overflow
log in
76
apk
share
5 Answers
180
Asked
Jul 9 '12 at 9:19
Edited
Jan 27 '15 at 16:18
Order By
Votes
startActivity(LaunchIntent);
share
Answered
Jul 9 '12 at 9:25
David Passmore
3,867 2 26 49
Edited
Mar 31 '15 at 18:55
@Sathish: I hope it may helpful for you Aerrow Jul 9 '12 at 9:57
No doubt your post is really helpful , but i am getting a exception "java.lang.RuntimeException: Adding window failed" and " E/AndroidRuntime(7554): Caused by:
android.os.TransactionTooLargeException 05-14 11:37:25.305: E/AndroidRuntime(7554): at android.os.BinderProxy.transact(Native Method) 05-14 11:37:25.305:
E/AndroidRuntime(7554): at android.view.IWindowSession$Stub$Proxy.add(IWindowSession.java:516) 05-14 11:37:25.305: E/AndroidRuntime(7554): at
android.view.ViewRootImpl.setView(ViewRootImpl.java:494) " Dilshad May 14 '14 at 6:16
@BlueGreen: Hi,hope this link may help you, stackoverflow.com/questions/11451393/, else if you are using Dialog Class means kindly check it. :) Aerrow May 14 '14
at 6:19
@Aerrow.. Suppose i am checking my .apk is installed or nor ? at time of installation... I am getting same exception while checking my package
com.test.installedornot.My .apk size is more than 9MB then in that case how i will manage this exception? Dilshad May 14 '14 at 6:39
show 3 more comments
19
The above code didn't work for me. The following approach worked.
Create an Intent object with appropriate info and then check if the Intent is callable or not using the following function:
private boolean isCallable(Intent intent) {
List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
share
This is better because it doesn't require using exceptions for flow control! QED Aug 29 '15 at 22:11
Answered
Jul 10 '13 at 3:10
Edited
Aug 29 '13 at 20:55
@QED it's appalling the amount of people using Exceptions as if statements! This is definitely the right answer AlanChavez Sep 7 '15 at 19:44
what's the content of the Intent? the String with the packageName doesn't work Henrique de Sousa Nov 18 '15 at 17:42
14
Somewhat cleaner solution than the accepted answer (based on this question):
public static boolean isAppInstalled(Context context, String packageName) {
try {
context.getPackageManager().getApplicationInfo(packageName, 0);
return true;
}
catch (PackageManager.NameNotFoundException e) {
return false;
}
}
This answer shows how to get the app from the Play Store if the app is missing, though care needs to be taken on devices that don't
have the Play Store.
share
Answered
Jan 27 '15 at 16:27
Edited
Jun 10 '15 at 8:28
If you know the package name, then this works without using a try-catch block or iterating through a bunch of packages:
public static boolean isPackageInstalled(Context context, String packageName) {
final PackageManager packageManager = context.getPackageManager();
Intent intent = packageManager.getLaunchIntentForPackage(packageName);
if (intent == null) {
return false;
}
List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
share
This code checks to make sure the app is installed, but also checks to make sure it's enabled.
private boolean isAppInstalled(String uri) {
PackageManager pm = getPackageManager();
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
if(this.getPackageManager().getApplicationInfo(uri, 0).enabled) {
return true;
} else {
return false;
}
share
}
catch (PackageManager.NameNotFoundException e) {
return false;
}
Answered
Jun 8 '15 at 11:41
youravgjoe
13 6
Answered
20 hours ago
Your Answer
log in
or
Name
By posting your answer, you agree to the privacy policy and terms of service.
meta chat tour help blog privacy policy legal contact us full site
Download the Stack Exchange Android app
2016 Stack Exchange, Inc