如何把网页添加到手机屏幕上,快捷小图标!安卓系统!

2025-03-23 11:43:49
推荐回答(4个)
回答1:

Android应用,创建桌面图标先在注册activity时,需要添加一个action为android.intent.action.CREATE_SHOERTCUT的intentFilter。

1.创建图标代码如下:






2.接下来就是就是设置快捷方式的图标、名称、事件等属性。

public void createShortCut(){
Intent addShortCut;
if(getIntent().getAction().equals(Intent.ACTION_CREATE_SHORTCUT)){//判断是否需要添加快捷方式
addShortCut = new Intent();
addShortCut.putExtra(Intent.EXTRA_SHORTCUT_NAME , "快捷方式");//快捷方式的名称
Parcelable icon = ShortcutIconResource.fromContext(this, R.drawable.icon);//显示的图片
addShortCut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);//快捷方式激活的activity,需要执行的intent,自己定义
addShortCut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent());
setResult(RESULT_OK, addShortCut);//OK,生成
}else{//取消
setResult(RESULT_CANCELED);
}
}

3.向桌面再增加一个图标
Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); //快捷方式的名称
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
shortcut.putExtra("duplicate", false); //不允许重复创建
//指定当前的Activity为快捷方式启动的对象: 如 com.everest.video.VideoPlayer
//注意: ComponentName的第二个参数必须加上点号(.),否则快捷方式无法启动相应程序
// ComponentName comp = new ComponentName(this.getPackageName(), "."+this.getLocalClassName());
// shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).setComponent(comp));
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(this,WXEntryActivity.class));//快捷方式的图标
ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
sendBroadcast(shortcut);

回答2:

这个是浏览器软件功能,以UC为例:打开网页后,菜单-- 收藏网址--选择收藏到桌面;

回答3:

手机自带浏览器不一样,步骤也就不同,不好说。。。推荐下载uc浏览器点击收藏网址,点击手机桌面就行了

回答4:

恩德