-1

ブラウザで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);
}

問題

ショートカットを開くと、非表示にしたいURLがブラウザに表示されます。これどうやってするの?

4

1 に答える 1

1

アプリケーションで WebView を使用するだけです

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
mWebView = (WebView) findViewById(R.id.webView1);
mWebView.loadUrl("http://www.google.com");

 }
于 2013-04-02T12:23:59.493 に答える