我正在尝试使用警报对话框来允许用户按下确定按钮并打开一个新活动。下面是我的代码:
我的第一个活动
AlertDialog.Builder dialog= new AlertDialog.Builder(context);
dialog.setTitle("Welcome");
dialog.setMessage("Please click ok");
dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent("com.thewildOnz.myResult");
startActivity(intent);
}
});
dialog.show();
新活动
public class myResult extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.result);
显现:
</activity>
<activity
android:name=".myResult"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.thewildOnz.myResult" />
<category android:name="android.intent.category.DEFUALT" />
</intent-filter>
</activity>
但是我得到了错误:
java.lang.NullPointerException
我错过了什么?