我从广播接收器,当它接收到的意图,我想开始/恢复活动。 截至点开始活动一切正常,我得到的意图等。
但我不能启动我的活动。
这是我的Android清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.imgzine.testing"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".WebViewActivity"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:name="com.imgzine.testing.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
下面是我尝试启动活动:
package com.imgzine.testing;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebView;
public class WebViewActivity extends Activity {
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
Log.w("DEBUG", "Hello, I'm a webview");
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.google.com");
}
}
这里是我的广播接收器的从那里我尝试启动该活动的一部分:
Log.w("DEBUG", "Hello, I receive.");
Intent webviewintent = new Intent(webviewcontext,
WebViewActivity.class);
webviewintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
webviewintent.setAction(Intent.ACTION_MAIN);
webviewintent.addCategory(Intent.CATEGORY_LAUNCHER);
webviewcontext.startActivity(webviewintent);
我要在这里澄清,webviewcontext是我的主要活动的情况下,我在这里使其通过广播接收器的构造。 我创建的主要活动的广播接收器:
BroadcastReceiver mReceiver = new MyPhoneReceiver(context);
registerReceiver(mReceiver, filter);
然而,活动不会启动。这里是我得到的日志:
11-16 12:47:36.144: W/DEBUG(818): Hello, I receive.
11-16 12:47:36.144: I/ActivityManager(58): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.imgzine.testing/.WebViewActivity }
任何想法更是值得欢迎的。
先感谢您。