AndroidManifest:<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="example.com.activitytest"> <application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".FirstActivity"
android:label="This is FirstActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> <activity android:name=".SecondActivity">
<intent-filte>
<actioin android:name="example.com.activitytest.ACTION_START"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filte>
</activity>
</application></manifest>
FirstActivity:protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.first_layout);
Button button1 = (Button)findViewById(R.id.button_1);
button1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Intent intent = new Intent();
intent.setAction("example.com.activitytest.ACTION_START");
startActivity(intent);
}
}); }
报错一直显示无法 No Activity found to handle Intent{ act=example.com.activitytest.ACTION_START },但是.....我代码找不出问题啊,改写的都写了啊。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="example.com.activitytest"> <application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".FirstActivity"
android:label="This is FirstActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> <activity android:name=".SecondActivity">
<intent-filte>
<actioin android:name="example.com.activitytest.ACTION_START"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filte>
</activity>
</application></manifest>
FirstActivity:protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.first_layout);
Button button1 = (Button)findViewById(R.id.button_1);
button1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Intent intent = new Intent();
intent.setAction("example.com.activitytest.ACTION_START");
startActivity(intent);
}
}); }
报错一直显示无法 No Activity found to handle Intent{ act=example.com.activitytest.ACTION_START },但是.....我代码找不出问题啊,改写的都写了啊。
2 自己实现一个ComponentName
3 intent.setComponen(ComponentName)
4 startActivity(intent)