我收到错误“无法启动活动ComponentInfo ”。
当我拨打 start_salud 功能时:
public void start_salud(View view) {
Intent intent = new Intent(MainActivity.this, salud.class);
startActivity(intent);
}
它在startActivity(intent)
我是从android:onClick="start_salud"
打来的。
salud_class:
package com.alertavecino.alertavecino;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;
import java.util.ArrayList;
public class salud extends AppCompatActivity {
ArrayList<String> listDiseases;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.salud_layout);
}
}
配音结果:
if (mResolvedMethod == null) { // <-- This statment is true
resolveMethod(mHostView.getContext(), mMethodName);
}
try {
mResolvedMethod.invoke(mResolvedContext, v); // <-- Here it's crashes
} catch (IllegalAccessException e) {
throw new IllegalStateException(
"Could not execute non-public method for android:onClick", e);
} catch (InvocationTargetException e) {
throw new IllegalStateException(
"Could not execute method for android:onClick", e);
}
的Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.alertavecino.alertavecino">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Alerta Vecino!"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Cat Log:
11-25 20:17:31.924 29226-29226 / com.alertavecino.alertavecino E / Zygote:MountEmulatedStorage() 11-25 20:17:31.924 29226-29226 / com.alertavecino.alertavecino E / Zygote:v2 11-25 20:17:31.944 29226-29226 / com.alertavecino.alertavecino E / SELinux:[DEBUG] get_category:变量seinfo:默认灵敏度:NULL,cateogry:NULL
答案 0 :(得分:0)
您必须在清单中注册所有活动,您可以这样做:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.alertavecino.alertavecino">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Alerta Vecino!"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".salud" >
</activity>
</application>
</manifest>
答案 1 :(得分:0)
您需要在清单中声明您的活动,以便能够启动它。
将以下内容添加到<activity android:name=".salud">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
标记内的manifest.xml文件中:
array.GroupBy(item => item.Group)
这将允许您的活动启动,并且还可以从设备应用列表中启动活动。