如何通过单击按钮打开谷歌图书应用程序

时间:2014-08-10 18:10:30

标签: java android

你好我正在建立一个教育启动器我有一个按钮,我需要它从设备打开谷歌书籍应用程序继承人代码到按钮:

case 3:
                        if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
                            setMenuLeftIconColor(view, 1);
                        }
                        if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
                            if (appMode == 3) {
                                setAppMode(0);
                            }
                            else {
                                if ((motionEvent.getEventTime() - motionEvent.getDownTime()) <= 300) {
                                    setMenuLeftIconColor(view, 0);
                                    try {
                                        startActivity(new Intent("googlebooks code here", null));
                                    }
                                    catch (Exception e) {
                                        Toast.makeText(context, "Google Books is NOT Installed", Toast.LENGTH_SHORT).show();
                                    }
                                }
                                else {
                                    setAppMode(3);
                                }
                            }
                        }
                        break;

任何帮助都会很棒

先谢谢你们

克里斯

1 个答案:

答案 0 :(得分:0)

Google Play Books的包名称为com.google.android.apps.books(网址末尾)。使用它,您可以使用以下代码启动应用程序:

String PLAY_BOOKS_PACKAGE_NAME = "com.google.android.apps.books";
PackageManager packageManager = context.getPackageManager();
Intent launchIntent = packageManager
    .getLaunchIntentForPackage(PLAY_BOOKS_PACKAGE_NAME);
if (launchIntent != null) {
    startActivity(launchIntent);
} else {
    Toast.makeText(context, "Google Books is NOT Installed",
        Toast.LENGTH_SHORT).show();
}