-1

I am creating a shortcut at home screen of device to open an url in browser as

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);
}

Problem

When I open the shortcut it shows the url into browser, that I want to hide. How can I do this?

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 回答