I am creating a navigations app to the application settings.
For that I am creating the following code, but, as I mention above in Title, I am getting a Syntax Error.
Kindly Guide me through this problem.
here is my 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
}
});
}
}
MainActivity(){}and what the hell isfinal MainActivity this$0;? andthis$0 = MainActivity.this;And this is insane:setContentView(0x7f030000);(you should use R.layout.your_layout_name, instead). This is also harmful:super(); //Constructor call must be the first statement in a constructorthis$0.