【求助】使用intent-filter跳转activity出错
2014-10-22 00:00
253 查看
============问题描述============
/*
Intent intent=new Intent();
intent.setClass(MainActivity.this, Activity02.class);
intent.setData(Uri.parse("Hello"));
this.startActivity(intent);
*/
Intent intent=new Intent("com.example.app08.Activity02" );
intent.setData(Uri.parse("Hello"));
startActivity(intent);
我使用注释里面的代码可以正常打开新的activity,而用其下面的那一段程序就会崩溃,我想不出是什么原因,大家帮忙分析一下。
manifest.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app08"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="14" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.app08.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>
<activity
android:name="com.example.app08.Activity02"
android:label="@string/Activity02"
android:theme="@android:style/Theme.Dialog">
<intent-filter>
<action android:name="com.example.app08.Activity02" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
============解决方案1============
Intent intent=new Intent("com.example.app08.Activity02" );
这里的com.example.app08.Activity02是action参数,你都没指定class怎么跳转啊
============解决方案2============
你可以这样写,Intent intent=new Intent(MainActivity.this, Activity02.class );
============解决方案3============
引用 4 楼 DR_TITI 的回复:
后面的代码是我在书上看到的,试了不行,我以为代码是正确的,是我自己哪里写错了。
就按你能用的方法写就行了
/*
Intent intent=new Intent();
intent.setClass(MainActivity.this, Activity02.class);
intent.setData(Uri.parse("Hello"));
this.startActivity(intent);
*/
Intent intent=new Intent("com.example.app08.Activity02" );
intent.setData(Uri.parse("Hello"));
startActivity(intent);
我使用注释里面的代码可以正常打开新的activity,而用其下面的那一段程序就会崩溃,我想不出是什么原因,大家帮忙分析一下。
manifest.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app08"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="14" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.app08.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>
<activity
android:name="com.example.app08.Activity02"
android:label="@string/Activity02"
android:theme="@android:style/Theme.Dialog">
<intent-filter>
<action android:name="com.example.app08.Activity02" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
============解决方案1============
Intent intent=new Intent("com.example.app08.Activity02" );
这里的com.example.app08.Activity02是action参数,你都没指定class怎么跳转啊
============解决方案2============
你可以这样写,Intent intent=new Intent(MainActivity.this, Activity02.class );
============解决方案3============
引用 4 楼 DR_TITI 的回复:
Quote: 引用 1 楼 sagittarius1988 的回复:
Intent intent=new Intent("com.example.app08.Activity02" );
这里的com.example.app08.Activity02是action参数,你都没指定class怎么跳转啊
Intent intent=new Intent("com.example.app08.Activity02" );
这里的com.example.app08.Activity02是action参数,你都没指定class怎么跳转啊
后面的代码是我在书上看到的,试了不行,我以为代码是正确的,是我自己哪里写错了。
就按你能用的方法写就行了
相关文章推荐
- 【求助】使用intent-filter跳转activity出错
- 使用Intent filter来实现不同应用中Activity的相互跳转
- 使用Intent来进行隐式activity跳转时Uri的作用
- 【Android】使用Intent实现Activity之间的跳转(创建一个Activity的过程)
- Android中的Handler+使用Intent进行Activity间的跳转
- 使用Intent filter 匹配相应的Activity or services
- 使用Intent实现Activity之间传值与跳转(转)
- Activity中使用Intent实现页面跳转与参数的传递
- Android Activity中使用Intent实现页面跳转与参数传递的方法
- Android 使用多个Intent 进行activity跳转 而没有finish的情况,如何直接退出系统
- android中使用intent来实现Activity带数据跳转
- 使用Intent实现Activity之间传值与跳转
- Android 使用Intent实现Activity跳转和数据传递
- 安卓--使用Intent实现Activity之间传值与跳转
- Android使用intent跳转到其它应用activity界面
- android中使用intent来实现Activity带数据跳转
- 使用Intent 的用法startActivity,使用intent-filter描述Activity的特征,使用setActiony设置action
- 怎样在继承自BaseAdapter类的adapter中使用Intent跳转到另一个activity
- Android学习笔记(四):在Activity中跳转--Intent的使用
- 使用Intent实现Activity之间传值与跳转