简体   繁体   中英

Download Google Play Services

In my android app I use google play services to view google maps

When a device does now have google play services installed, android shows a button says "Get Google Play Services" this button is from android itself, i did not create it.

the problem is that when ever user click on that button, app crashes.

I tried to trace the code and debug but there is no code for this ( i did not create any code for it)

I get this error, not sure how this can be resolved.

any ideas?

Thanks

05-06 23:58:17.730    2695-2695/com.asmgx.schlogger.app D/AndroidRuntime﹕ Shutting down VM
05-06 23:58:17.730    2695-2695/com.asmgx.schlogger.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.asmgx.schlogger.app, PID: 2695
    android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.google.android.gms flg=0x80000 pkg=com.android.vending }
            at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1781)
            at android.app.Instrumentation.execStartActivity(Instrumentation.java:1501)
            at android.app.Activity.startActivityForResult(Activity.java:3745)
            at android.app.Activity.startActivityForResult(Activity.java:3706)
            at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
            at android.app.Activity.startActivity(Activity.java:4016)
            at android.app.Activity.startActivity(Activity.java:3984)
            at com.google.android.gms.dynamic.zza$5.onClick(Unknown Source)
            at android.view.View.performClick(View.java:4780)
            at android.view.View$PerformClick.run(View.java:19866)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5257)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

You receive this error because you are running your code on an Android device that doesn't have the Google Play Store.

You can check if your intent will succeed like this:

if (intent.resolveActivity(getPackageManager()) != null) {
    startActivity(intent);
} else {
    //There isn't an app that handle your intent
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM