我正在尝试在ontouchEvent中的android中加载浏览器视图的意图.基本上,我已经创建了一个动态壁纸,如果单击它,那么我想使用指定的uri打开浏览器意图.
我试过了ontouchEvent内部的以下代码
Uri uri = Uri.parse("http://www.Google.com");Intent intent = new Intent(Intent.ACTION_VIEW, uri);startActivity(intent);
但我收到以下错误:
androID.util.AndroIDRuntimeException: Calling startActivity() from outsIDe of an Activitycontext requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
另一种方法是,我创建了一个活动,并在其onCreate方法中尝试了以下代码:
public voID onCreate(Bundle icicle) { super.onCreate(icicle); browser=new WebVIEw(this); setContentVIEw(browser); browser.loadUrl("http://commonsware.com");}
并尝试通过自定义意图消息加载此活动,如下所示,但仍然出现相同的错误
Intent intent = new Intent(ACTION);startActivity(intent);// over here I have not used context, as while creating live wallpaper I// don't kNow here to get the context
解决方法:
我已使用以下代码自行解决了该问题:
Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);intent.setData(androID.net.Uri.parse("http://www.gmail.com"));startActivity(intent);
总结 以上是内存溢出为你收集整理的android-在动态壁纸中启动浏览器意图全部内容,希望文章能够帮你解决android-在动态壁纸中启动浏览器意图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)