-1
我創建的設備的主屏幕上的快捷方式在瀏覽器中打開一個URL作爲打開網址,但不顯示的URL
public void addBookmarks(MyBookMarks bookMarks) {
Log.d(TAG, "Creating Bookmarks for " + bookMarks.getUrl());
final Intent intent = new Intent();
final Intent shortcutIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(bookMarks.getUrl()));
long urlHash = bookMarks.getUrl().hashCode();
long uniqueId = (urlHash << 32) | shortcutIntent.hashCode();
shortcutIntent.putExtra(Browser.EXTRA_APPLICATION_ID, Long.toString(uniqueId));
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, bookMarks.getLabel());
if (bookMarks.getBookMarkIcon() != null) {
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON,
Bitmap.createScaledBitmap(bookMarks.getBookMarkIcon(), 128, 128, true));
} else {
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, "");
}
//intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bookMarks.getBookMarkIcon());
intent.putExtra("duplicate", false);
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
//intent.setAction(Intent.ACTION_CREATE_SHORTCUT);
this.mContext.sendBroadcast(intent);
}
問題
當我打開它將快捷方式顯示到瀏覽器中的網址,我想隱藏。我怎樣才能做到這一點?
您應該使用[的WebView(http://developer.android.com/reference/android/webkit/WebView.html)。 – adrianp
我正在創建一個類似於應用程序快捷方式的快捷方式。 –
隱藏地址欄幾乎是不可能的,因爲您無法控制各種Android Web瀏覽器。你需要做的是創建一個活動,在「WebView」中顯示該頁面,然後如上所述啓動它。 – adrianp