我有一个错误的" unforunatly sotp"我想首先打开splesh然后MainActivity然后从main Activity有一个菜单,它给我打开检查类的选项...我得到错误pzz帮助我 AndroidManifest代码
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.fypproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application android:icon="@drawable/fypicon"
android:label="@string/app_name">
<activity
android:name=".Splesh"
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.fypproject.Check"
android:label="@string/app_name">
<intent-filter>
<action android:name="com.example.fypproject.CHECK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.example.fypproject.MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name=".SMSReceiver">
<intent-filter>
<action android:name=
"android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
</manifest>
这是我的MainActivity
package com.example.fypproject;
import android.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b1,b2;
b1= (Button)findViewById(R.id.bmenu);
b1.setOnCreateContextMenuListener(this);
}
@Override
public void onCreateContextMenu(ContextMenu menu1, View v,
ContextMenuInfo menuInfo) {
// TODO Auto-generated method stub
super.onCreateContextMenu(menu1, v, menuInfo);
CreateMenu(menu1);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
// TODO Auto-generated method stub
return MenuChoice(item);
}
private void CreateMenu(Menu menu){
MenuItem mnu1 = menu.add(0,0,0,"Check Status");
{
mnu1.setIcon(R.drawable.ic_launcher);
}
MenuItem mnu2 = menu.add(0,1,1,"Contact Us");
{
mnu2.setIcon(R.drawable.ic_launcher);
}
MenuItem mnu3 = menu.add(0,2,2,"About Us");
{
mnu3.setIcon(R.drawable.ic_launcher);
}
}
private boolean MenuChoice(MenuItem item){
switch(item.getItemId()) {
case 0:
//Toast.makeText(this, "This is item1", Toast.LENGTH_SHORT).show();
startActivity(new Intent(this,Check.class));
return true;
case 1:
startActivity(new Intent(this,ContactUs.class));
return true;
case 2:
startActivity(new Intent(this,AboutUs.class));
return true;
}
return false;
}
}
这是我的MainActivity XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="70dp"
android:gravity="center"
android:text="Fyp Project"
android:textSize="20sp" />
<Button
android:id="@+id/bmenu"
android:layout_width="475sp"
android:layout_height="70sp"
android:text="Menu"
android:textSize="30sp"
android:gravity="center"
></Button>
</LinearLayout>
答案 0 :(得分:0)
您提到的操作是xx.xxx.aziz.Mainactivity。但根据你的Manifest,MainActivity似乎有一个意图过滤动作
android.intent.action.MAINACTIVITY
因此,要么修改调用操作,要么修改清单以匹配调用操作