java - Cannot use this in a static context -


having problem on below coding.

new alertdialog.builder(this) 

the having error, please me have look.

import java.io.file; import android.app.alertdialog; import android.content.dialoginterface; import android.support.v7.app.actionbaractivity;  public class mainactivity extends actionbaractivity {           public static boolean isphonerooted() {              // build info             string buildtags = android.os.build.tags;             if (buildtags != null && buildtags.contains("test-keys")) {               return true;             }              // check if /system/app/superuser.apk present             try {               file file = new file("/system/app/superuser.apk");               if (file.exists()) {                    new alertdialog.builder(this)                      .seticon(r.drawable.ic_launcher)                      .settitle("[" + file.getname() + "] folder can't read!")                      .setpositivebutton("ok",                         new dialoginterface.onclicklistener() {                              @override                         public void onclick(dialoginterface dialog, int which) {                          // todo auto-generated method stub                         }                        }).show();                }             } catch (throwable e1) {               // ignore             }              return false;           } } 

here:

public static boolean isphonerooted() {   ...   new alertdialog.builder(this)   .... } 

is explicitly not allowed.

because method class method , not instance method, this doesn't exist (because this actual instance of thing).

this real basic stuff, should read on it. here's link comparing two.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -