Hun*_*unt 3 android wallpaper live-wallpaper
我想在android里面加载BROWSER VIEW意图onTouchEvent.基本上我已经创建了一个动态壁纸,如果我点击它,那么我想用指定的uri打开BROWSER VIEW意图.
我试过里面的代码 onTouchEvent
Uri uri = Uri.parse("http://www.google.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
android.util.AndroidRuntimeException: Calling startActivity() from outside of
an Activitycontext requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
Run Code Online (Sandbox Code Playgroud)
另一种方法是我创建了一个活动,在其onCreate方法中我尝试了以下代码:
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
browser=new WebView(this);
setContentView(browser);
browser.loadUrl("http://commonsware.com");
}
Run Code Online (Sandbox Code Playgroud)
并尝试通过自定义意图消息加载此活动,如下所示,但我仍然得到相同的错误
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
Run Code Online (Sandbox Code Playgroud)
我用以下代码自己解决了这个问题:
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);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1504 次 |
| 最近记录: |