我正在为应用程序设置创建一个导航应用程序。
为此,我正在创建以下代码,但是,正如我在上面的标题中提到的那样,我遇到了语法错误。
请引导我解决这个问题。
这是我的MainActivity.Java
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
public MainActivity() {
}
private boolean MyStartActivity(Intent intent) {
try {
startActivity(intent);
} catch (ActivityNotFoundException activitynotfoundexception) {
return false;
}
return true;
}
protected boolean isAppInstalled(String s) {
PackageManager packagemanager = getPackageManager();
try {
packagemanager.getPackageInfo(s, 128);
} catch (android.content.pm.PackageManager.NameNotFoundException namenotfoundexception) {
return false;
}
return true;
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(0x7f030000);
if (getIntent().getIntExtra("reload", 0) == 1) {
if (isAppInstalled("com.sample.test")) {
Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
intent.addCategory("android.intent.category.DEFAULT");
intent.setData(Uri.parse("package:com.sample.test"));
startActivity(intent);
} else {
Toast.makeText(getApplicationContext(), "Game Not Instaled", 0).show();
}
}
((Button)findViewById(0x7f080000)).setOnClickListener(new android.view.View.OnClickListener() {
final MainActivity this$0;
public void onClick(View view) {
if (isAppInstalled("com.sample.test")) {
Intent intent1 = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
intent1.addCategory("android.intent.category.DEFAULT");
intent1.setData(Uri.parse("package:com.sample.test"));
startActivity(intent1);
return;
} else {
Toast.makeText(getApplicationContext(), "Game Not Instaled", 0).show();
return;
}
}
{
this$0 = MainActivity.this;
super(); //Constructor call must be the first statement in a constructor
}
});
}
}
您创建了一个匿名内部类:
new android.view.View.OnClickListener() {
// code exists here
super();
}
在该类的底部,您调用的super();
是超级构造函数调用。此调用必须是第一个,但对于您而言,则完全没有必要。只需将其删除。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句