首页 > 代码库 > android--手机桌面增加网址链接图标(解决方案)

android--手机桌面增加网址链接图标(解决方案)

这种做法最普遍最简单:

1、新建一个android空项目;

2、在drawable目录下添加图标文件,如icon.png;在values目录下的strings.xml文件中增加名称,如websitename。

3、在配置文件AndroidManifest.xml中,增加链接的图标icon和名称websitename:

<application android:label="@string/name" android:icon="@drawable/icon">
4、在MainActivity中编辑onCreate方法:

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		Uri uri = Uri.parse("http://blog.csdn.net/wanggsx918");  
		Intent it = new Intent(Intent.ACTION_VIEW, uri);  
		startActivity(it);
		finish();
	}

没错,就是这么简单!

如果想做得更好,就在应用中增加webview浏览器功能。

android--手机桌面增加网址链接图标(解决方案)