我正在制作一个应用程序,在其中我获得手机上安装应用程序的列表,然后我从我的应用程序中点击并打开这些应用程序。但是这里提出的问题CATEGORY_LAUNCHER
给出了空指针
我的 logcat 输出::
05-30 14:34:33.876: E/Handler(14042): Failed to handle callback; interface not implemented, callback:android.view.View$PerformClick@40e35d70
05-30 14:34:33.876: E/Handler(14042): java.lang.NullPointerException
05-30 14:34:33.876: E/Handler(14042): at com.AppFavorits.GetAllApp$1$1.onClick(GetAllApp.java:83)
05-30 14:34:33.876: E/Handler(14042): at android.view.View.performClick(View.java:3538)
05-30 14:34:33.876: E/Handler(14042): at android.widget.CompoundButton.performClick(CompoundButton.java:105)
05-30 14:34:33.876: E/Handler(14042): at android.view.View$PerformClick.run(View.java:14330)
05-30 14:34:33.876: E/Handler(14042): at android.os.Handler.handleCallback(Handler.java:607)
05-30 14:34:33.876: E/Handler(14042): at android.os.Handler.dispatchMessage(Handler.java:92)
05-30 14:34:33.876: E/Handler(14042): at android.os.Looper.loop(Looper.java:154)
05-30 14:34:33.876: E/Handler(14042): at android.app.ActivityThread.main(ActivityThread.java:4974)
05-30 14:34:33.876: E/Handler(14042): at java.lang.reflect.Method.invokeNative(Native Method)
05-30 14:34:33.876: E/Handler(14042): at java.lang.reflect.Method.invoke(Method.java:511)
05-30 14:34:33.876: E/Handler(14042): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-30 14:34:33.876: E/Handler(14042): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-30 14:34:33.876: E/Handler(14042): at dalvik.system.NativeStart.main(Native Method)
我的代码:: 更新
final Dialog dialog = new Dialog(GetAllApp.this);
dialog.setContentView(R.layout.maindialog);
dialog.setTitle("This is my custom dialog box");
dialog.setCancelable(true);
//there are a lot of settings, for dialog, check them all out!
//set up text
final RadioButton rdoDialogopen = (RadioButton)dialog.findViewById(R.id.rdoDialogopen);
final RadioButton rdoDialogfav = (RadioButton)dialog.findViewById(R.id.rdoDialogfav);
final RadioButton rdoDialogopenNfav = (RadioButton)dialog.findViewById(R.id.rdoDialogopenNfav);
rdoDialogopen.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (rdoDialogopen.isChecked() == true) {
if(lstpinfo.get(position).pname !=null)
{
Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager manager = getPackageManager();
i = manager.getLaunchIntentForPackage(lstpinfo
.get(position).pname);
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
}
}
}
});