-2

I get a weird error on my Android app. I couldn't found any useful source about this error:

java.lang.NullPointerException
at org.uusoftware.burclar.a.a$1$1.onClick(Unknown Source)
at android.support.v7.a.d$a$3.onItemClick(Unknown Source)
at android.widget.AdapterView.performItemClick(AdapterView.java:308)
at android.widget.AbsListView.performItemClick(AbsListView.java:1509)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3467)
at android.widget.AbsListView$3.run(AbsListView.java:4830)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)

I couldn't detect where gives this error neither which code block gives this error in the app. Thanks.

Addition: Here is the my project on Github: https://github.com/aykutuludag/GunlukBurclar

Addition 2: Here is my app on Google Play: https://play.google.com/store/apps/details?id=org.uusoftware.burclar

Addition 3: I suspect app crashes on these code block but I don't know why it crashes:

View.OnClickListener clickListener = new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        ViewHolder holder = (ViewHolder) view.getTag();
        final int position = holder.getPosition();

        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setTitle(R.string.chooseaction);
        builder.setItems(R.array.choose_actions, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // Get Uri
                String path = Environment.getExternalStorageDirectory().toString() + "/Günlük Burçlar";
                File f = new File(path);
                File file[] = f.listFiles();
                Intent intent = new Intent();
                if (which == 0) {
                    // Show
                    intent.setAction(android.content.Intent.ACTION_VIEW);
                    intent.setDataAndType(Uri.fromFile(file[position]), "image/*");
                    mContext.startActivity(intent);
                } else if (which == 1) {
                    // Share
                    intent.setAction(Intent.ACTION_SEND);
                    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file[position]));
                    intent.setType("image/*");
                    mContext.startActivity(intent);
                } else {
                    // Delete
                    file[position].delete();
                    Toast.makeText(mContext, R.string.deleted, Toast.LENGTH_SHORT).show();
                    intent = new Intent(mContext, FavoritesActivity.class);
                    mContext.startActivity(intent);
                    ((FavoritesActivity) mContext).finish();
                }
            }
        });
        builder.show();
    }
};
halfer
  • 19,824
  • 17
  • 99
  • 186
Aykut Uludağ
  • 1,876
  • 5
  • 18
  • 34

1 Answers1

1

I found error finally. Unfortunately reason of crash is Turkish characters.

Wrong

String path = Environment.getExternalStorageDirectory().toString() + "/Günlük Burçlar";

True

String path = Environment.getExternalStorageDirectory().toString() + "/Günlük Burçlar";
Aykut Uludağ
  • 1,876
  • 5
  • 18
  • 34