【发布时间】:2015-05-20 02:58:07
【问题描述】:
我有一个非常具体的问题。我在安卓平板上实现了一个Web App,将用于展览(Outform iDisplay)。因此,Web App 必须在启动后直接启动。启动后没有问题(使用“android.permission.RECEIVE_BOOT_COMPLETED”进行广播),但我无法将 Chrome 作为 Web 应用程序启动。为了获得 Intent,我已经用这个 sn-p 阅读了启动器收藏夹中的图标:
//Kitkat, therefore launcher3
url = "content://com.android.launcher3.settings/favorites?Notify=true";
ContentResolver resolver = getContentResolver();
Cursor cursor = resolver.query(Uri.parse(url), null, null, null, null);
if (cursor != null && cursor.moveToFirst())
{
do
{
String ent1 = cursor.getString(0);
String ent2 = cursor.getString(1);
String ent3 = cursor.getString(2); //there is the Intent string
String ent4 = cursor.getString(3);
System.out.println("Test");
String ent5 = cursor.getString(4);
String ent6 = cursor.getString(5);
String ent7 = cursor.getString(6);
String ent8 = cursor.getString(7);
String ent9 = cursor.getString(8);
String ent10 = cursor.getString(9);
String ent11 = cursor.getString(10);
String ent12 = cursor.getString(11);
String ent14 = cursor.getString(13);
String ent15 = cursor.getString(14);
String ent17 = cursor.getString(16);
String ent18 = cursor.getString(17);
String ent19 = cursor.getString(18);
String ent20 = cursor.getString(19);
if(ent2.equals("History Book")) //Get the right intent
{
runAction = ent3;
}
System.out.println(ent3);
} while (cursor.moveToNext());
}
Intent 字符串包含如下内容:
#Intent;action=com.google.android.apps.chrome.webapps.WebappManager.ACTION_START_WEBAPP;package=com.android.chrome;S.org.chromium.chrome.browser.webapp_title=History%20Book;S.org.chromium.chrome.browser.webapp_id=86e362e4-a25d-4142-8a32-c02ffcb176a9;i.org.chromium.content_public.common.orientation=6;S.org.chromium.chrome.browser.webapp_icon=;S.org.chromium.chrome.browser.webapp_mac=3ZaXFbyWnJQaqFFOuUj3OssNz7DrBaaiWfzO2Dd7VIU%3D%0A;S.org.chromium.chrome.browser.webapp_url=http%3A%2F%2F192.168.5.148%2Fstyria%2Fhistorybook%2Findex.html;end
这看起来不错,但是我如何在一个只有一个目的的小应用程序中启动这样的 Intent?
最后只是一个小提示:我试图将这个东西打包成一个 webview,但是 webview 因为 libc 错误而不断死掉,所以这对我来说是没有选择的。
【问题讨论】:
标签: android google-chrome android-intent web-applications