请教各位一个问题,在Android启动后想弹出一个网页,然后点击back后返回到Home,我的方法是在Launcher中加了一个WebReceiver.java:
import static android.util.Log.e;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;public class WebReceiver extends BroadcastReceiver {
private final static String TAG = "WebReceiver";
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub Intent it = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.google.com/"));
it.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
try{
context.startActivity(it);
} catch (ActivityNotFoundException e){
Toast.makeText(context, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); } catch (SecurityException e){
Toast.makeText(context, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
e(TAG, "Homescreen does not have the permission to launch " + it +
". Make sure to create a MAIN intent-filter for the corresponding activity " +
"or use the exported attribute for this activity.", e);
} }}然后在AndroidManifest.xml中添加了如下:
<receiver
android:name=".WebReceiver"
android:enabled="true" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
编译是通过了,但是运行的过程中没有出现所想的。并且报错:“The process android.process.acore has stoped”
有过类似经验的兄弟姐妹请指导下,谢谢!
import static android.util.Log.e;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;public class WebReceiver extends BroadcastReceiver {
private final static String TAG = "WebReceiver";
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub Intent it = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.google.com/"));
it.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
try{
context.startActivity(it);
} catch (ActivityNotFoundException e){
Toast.makeText(context, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); } catch (SecurityException e){
Toast.makeText(context, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
e(TAG, "Homescreen does not have the permission to launch " + it +
". Make sure to create a MAIN intent-filter for the corresponding activity " +
"or use the exported attribute for this activity.", e);
} }}然后在AndroidManifest.xml中添加了如下:
<receiver
android:name=".WebReceiver"
android:enabled="true" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
编译是通过了,但是运行的过程中没有出现所想的。并且报错:“The process android.process.acore has stoped”
有过类似经验的兄弟姐妹请指导下,谢谢!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货