I want go to next page(mainActivity). I was able to sign up and send that information to the database. But only the success message and the ok button come out. Errors not come out. plz check my code.
LogingActivity.java
package com.life.registeration;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.Volley;
import org.json.JSONObject;
public class LoginActivity extends AppCompatActivity {
private AlertDialog dialog;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
TextView registerButton = (TextView) findViewById(R.id.registerButton);
registerButton.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View view) {
Intent registerIntent = new Intent(LoginActivity.this, RegisterActivity.class);
LoginActivity.this.startActivity(registerIntent);
}
});
final EditText idText = (EditText) findViewById(R.id.idText);
final EditText passwordText = (EditText) findViewById(R.id.passwordText);
final Button loginButton = (Button) findViewById(R.id.loginButton);
loginButton.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View view) {
String userID = idText.getText().toString();
String userPassword = passwordText.getText().toString();
Response.Listener<String> responseListener = new Response.Listener<String>(){
#Override
public void onResponse(String response) {
try {
JSONObject jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
if(success){
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
dialog = builder.setMessage("Login success.")
.setPositiveButton("ok", null)
.create();
dialog.show();
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
LoginActivity.this.startActivity(intent);
finish();
}
else{
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
dialog = builder.setMessage("please, check your id.")
.setNegativeButton("re try", null)
.create();
dialog.show();
}
}
catch (Exception e) {
e.printStackTrace();
}
}
};
LoginRequest loginRequest = new LoginRequest(userID, userPassword, responseListener);
RequestQueue queue = Volley.newRequestQueue(LoginActivity.this);
queue.add(loginRequest);
}
});
}
#Override
protected void onStop(){
super.onStop();
if(dialog != null){
dialog.dismiss();
dialog = null;
}
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.life.registeration">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme.NoActionBar">
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RegisterActivity" /><!-- ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
With answer of Prerak Sola add your Activity on Manifest.xml:
<activity android:name=".MainActivity" />
Use your .setPositiveButton properly , your OK click event is null - .setPositiveButton("ok", null):
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
}
}).create();
dialog.show();
You have not registered your MainActivity in AndroidManifest.xml file. Add the line <activity android:name=".MainActivity" /> in the manifest file. So it should look like:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.life.registeration">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme.NoActionBar">
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RegisterActivity" />
<activity android:name=".MainActivity" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
Related
i am a new app developer i was working on a app for the past few days i have implemented onclicklistner in my program then the error shows like this.i have been working on a cardview project please help me from this and i am using new version of andriod.
thank you
this is my Main activity:
package com.example.login;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.os.Handler;
import android.os.Handler;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private static int SPLASH_SCREEN = 4000;
private CardView d1,d2,d3,d4;
//varaibles
Animation topAnim, bottomAnim;
ImageView image;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
d1 = (CardView) findViewById(R.id.d1);
d2 = (CardView) findViewById(R.id.d2);
d3 = (CardView) findViewById(R.id.d3);
d4 = (CardView) findViewById(R.id.d4);
d1=null;
d2=null;
d3=null;
d4=null;
try {
d1.setOnClickListener((OnClickListener) this);
d2.setOnClickListener((OnClickListener) this);
d3.setOnClickListener((OnClickListener) this);
d4.setOnClickListener((OnClickListener) this);
}catch (NullPointerException ignored){
}
//Animation
topAnim = AnimationUtils.loadAnimation(this, R.anim.top_animation);
bottomAnim = AnimationUtils.loadAnimation(this, R.anim.bottom_animation);
//Hooks
image = findViewById(R.id.imageView);
image.setAnimation(topAnim);
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Intent intent = new Intent(MainActivity.this,dashboard2.class);
startActivity(intent);
finish();
}
}, SPLASH_SCREEN);
}
#Override
public void onClick(View v){
Intent i;
switch (v.getId()){
case R.id.d1: i = new Intent(this,d1.class); startActivity(i); break;
case R.id.d2: i = new Intent(this,d2.class); startActivity(i); break;
case R.id.d3: i = new Intent(this,d3.class); startActivity(i); break;
case R.id.d4: i = new Intent(this,d4.class); startActivity(i); break;
}
}
}
this is my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.login">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Login">
<activity
android:name=".d4"
android:exported="false" />
<activity
android:name=".d3"
android:exported="false" />
<activity
android:name=".d1"
android:exported="false" />
<activity
android:name=".d2"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
this is my logcat:
```Process: com.example.login, PID: 16401
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.login/com.example.login.dashboard2}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1933)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1616)
at android.app.Activity.startActivityForResult(Activity.java:4487)
at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:597)
at android.app.Activity.startActivityForResult(Activity.java:4445)
at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:583)
at android.app.Activity.startActivity(Activity.java:4806)
at android.app.Activity.startActivity(Activity.java:4774)
at com.example.login.MainActivity$1.run(MainActivity.java:61)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
enter code here
Activity dashboard2 is not declared in your Manifest
Solution: Add below tag in your Manifest
<activity
android:name=".dashboard2"
android:exported="false" />
I have problem with splash screen. It shows only for half a second and disappears a few seconds before activity HomeZastepowy appears. I made this splash screen based on this site https://android.jlelse.eu/right-way-to-create-splash-screen-on-android-e7f1709ba154. Where i made a mistake?
MainActivity code:
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;
import java.util.Objects;
public class MainActivity extends AppCompatActivity {
FirebaseAuth mAuth;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mAuth = FirebaseAuth.getInstance();
if (mAuth.getCurrentUser() != null) {
String uid = mAuth.getUid();
final DocumentReference mDocRef = FirebaseFirestore.getInstance().collection("Data").document("userInfo").collection(Objects.requireNonNull(uid)).document(uid);
mDocRef.get()
.addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
#Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
if (documentSnapshot.exists()) {
String user = documentSnapshot.getString("user");
assert user != null;
if (user.equals("user")) {
Log.d("tag", String.valueOf(mAuth.getUid()));
Intent intent = new Intent(getApplicationContext(),
HomeUsrActivity.class);
startActivity(intent);
finish();
} else {
Log.d("tag", "Zastepowy");
Log.d("tag", String.valueOf(mAuth.getUid()));
startActivity(new Intent(MainActivity.this, HomeZastepowy.class));
finish();
}
}
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(MainActivity.this, "Error", Toast.LENGTH_SHORT).show();
}
});
finish();
}else {
Intent intent = new Intent(getApplicationContext(),
HomeActivity.class);
startActivity(intent);
finish();
}
}
}
AndroidManifest code:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.zapp4">
<application
android:allowBackup="true"
android:fullBackupContent="#xml/backup_descriptor"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".HomeUsrActivity"></activity>
<activity android:name=".LoginActivity" />
<activity android:name=".punktyog" />
<activity android:name=".punktywz" />
<activity android:name=".HomeZastepowy" />
<activity android:name=".tradycje" />
<activity android:name=".wiedza" />
<activity android:name=".kontakt" />
<activity android:name=".zastepy" />
<activity android:name=".historia" />
<activity android:name=".onas" />
<activity android:name=".HomeActivity" />
<activity android:name=".MainActivity" android:theme="#style/SplashScreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I think the problem is that you forgot to remove this line from your code:
setContentView(R.layout.activity_main)
Because you setContentView, it overrides your theme background. So try to comment this line and give it a try.
i had implement this tutorial to using sharedpreferences, it's work for one user but when i do the same just add any string like that code it's just work too however it's always go to MainActivity not to Activity target what i want.
See my code: SessionManager.java
public class SessionManager {
SharedPreferences pref;
SharedPreferences.Editor editor;
Context context;
int PRIVATE_MODE = 0;
private static final String PREF_NAME = "SSA";
private static final String IS_LOGIN = "IsLoggedIn";
public static final String KEY_NAME = "name";
public static final String KEY_PETUGAS = "petugas";
public static final String KEY_HOTEL = "hotel";
public SessionManager(Context context) {
this.context = context;
pref = context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
editor = pref.edit();
}
public void createLoginSession(String name, String hotel) {
editor.putBoolean(IS_LOGIN, true);
editor.putString(KEY_NAME, name);
editor.putString(KEY_HOTEL, hotel);
editor.commit();
}
public void createPetugasSession(String petugas) {
editor.putBoolean(IS_LOGIN, true);
editor.putString(KEY_PETUGAS, petugas);
editor.commit();
}
public void checkLogin() {
if (!this.isLoggedIn()) {
Intent intent = new Intent(context, LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
public HashMap<String, String> getUserDetails() {
HashMap<String, String> user_SSA = new HashMap<String, String>();
user_SSA.put(KEY_NAME, pref.getString(KEY_NAME, null));
user_SSA.put(KEY_PETUGAS, pref.getString(KEY_PETUGAS, null));
user_SSA.put(KEY_HOTEL, pref.getString(KEY_HOTEL, null));
return user_SSA;
}
public void logOutUser() {
editor.clear();
editor.commit();
Intent intent = new Intent(context, LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
public boolean isLoggedIn() {
return pref.getBoolean(IS_LOGIN, false);
}}
LoginActivity.java
public class LoginActivity extends AppCompatActivity {
EditText username, password;
Button login;
AlertDialogManager alert = new AlertDialogManager();
SessionManager session;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
session = new SessionManager(getApplicationContext());
username = (EditText) findViewById(R.id.edt_username);
password = (EditText) findViewById(R.id.edt_password);
login = (Button) findViewById(R.id.btn_login);
login.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
String user = username.getText().toString();
String pass = password.getText().toString();
if (user.trim().length() > 0 && pass.trim().length() > 0) {
if (user.equals("admin_ssa") && pass.equals("ssa_rotary")) {
session.createLoginSession("Admin SSA", "Admin Hotel");
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
finish();
} else if (user.equals("admin_petugas") && pass.equals("petugas_rotary")) {
session.createPetugasSession("Admin Bandara");
Intent intent = new Intent(getApplicationContext(), ArrivedActivity.class);
startActivity(intent);
finish();
} else if (user.equals("admin_hotel") && pass.equals("hotel_rotary")) {
session.createLoginSession("Admin SSA", "Admin Hotel");
Intent intent = new Intent(getApplicationContext(), HotelManagementActivity.class);
startActivity(intent);
finish();
} else {
alert.showAlertDialog(LoginActivity.this, "Login Failed..",
"username or password is incorect", false);
}
} else {
alert.showAlertDialog(LoginActivity.this, "Login Failed..",
"Please enter username or password", false);
}
}
});
}}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kode.kreasi.rotarybarcode">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".Utils.BaseApps"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#drawable/rotarylogo"
android:supportsRtl="true"
android:theme="#style/NoActionBar">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".RegistrationMenuActivity"
android:label="Registration"
android:parentActivityName=".MainActivity"
android:theme="#style/AppTheme" />
<activity
android:name=".EventMenuActivity"
android:label="Event"
android:parentActivityName=".MainActivity"
android:theme="#style/AppTheme" />
<activity android:name=".ScanQRCodeActivity" />
<activity
android:name=".ManualActivity"
android:label="Manual Absent"
android:parentActivityName=".MainActivity"
android:theme="#style/AppTheme" />
<activity android:name=".LoginActivity" />
<activity android:name=".ArrivedActivity" />
<activity android:name=".HotelManagementActivity" />
<activity
android:name=".CheckInActivity"
android:label="Check In"
android:parentActivityName=".HotelManagementActivity"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
</activity>
<activity
android:name=".SummaryActivity"
android:label="Summary"
android:parentActivityName=".HotelManagementActivity"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="#xml/searchable" />
</activity>
<activity
android:name=".TourActivity"
android:label="Tour"
android:parentActivityName=".MainActivity"
android:theme="#style/AppTheme" />
<activity
android:name=".OnTheSpotActivity"
android:label="#string/onthespot"
android:parentActivityName=".HotelManagementActivity"
android:theme="#style/AppTheme" />
</application>
I think my code it's simple, but it's not working with my mine because actually i'm new. Hope you reply guys, thankyou.
See the gif
In the first time i put the user + pass is the right target activity, but when i close the apps it's back to MainActivity not the target Activity.
Where are using isLoggedIn() method? I don't see any implementation for that.
In the LoginActivity check for login with isLoggedIn() method
if(isLoggedIn()){
Toast.makeText(LoginActivity.this, "Is Login", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(getApplicationcontext(), SecondActivity.class);
startActivity(intent);
} else{
Toast.makeText(LoginActivity.this, "No Login", Toast.LENGTH_SHORT).show();
}
The android app I had created is not crashing in the emulator nor the phone I am using but shows some exceptions like java.lang.NoSuchMethodError: in the logcat, but when I transfer the apk file to other devices then 80% of the users reported the app got crashed while just opening the app or opening an activity with on the app.
This is driving me crazy I tested this on different emulators and none of them got crashed.I just couldn't understand what the problem is please help.
MY AndroidMaifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androgeekzz.pokemongo_bestguidetipsandtricks">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Basics" />
<activity android:name=".Tips" />
<activity android:name=".Tricks" />
<activity android:name=".Bas_What" />
<activity android:name=".Bas_Downld" />
<activity android:name=".Bas_Pikatchu" />
<activity android:name=".Bas_PokeCapture" />
<activity android:name=".Bas_LVI5" />
<activity android:name=".Bas_GainXP_LVL_Up" />
<activity android:name=".Bas_All_Iteams" />
<activity android:name=".Bas_All_Places" />
<activity android:name=".Advanced" />
<activity android:name=".Adv_gainXP" />
<activity android:name=".Adv_1candies" />
<activity android:name=".Adv_2Evolution" />
<activity android:name=".Adv_3PowerUp" />
<activity android:name=".Adv_4FightAGym" />
<activity android:name=".Adv_5DefendGym" />
<activity android:name=".Adv_6LvlGym" />
<activity android:name=".Adv_7Type" />
<activity android:name=".Adv_8Egg" />
<activity android:name=".Tips_0Good" />
<activity android:name=".Tips_1Eevee" />
<activity android:name=".Tips_2EarnXP" />
<activity android:name=".Tips_3Find" />
<activity android:name=".Tips_4Nest" />
<activity android:name=".Adv_Nests" />
<activity android:name=".Resources"></activity>
</application>
Main Activity:
package com.androgeekzz.pokemongo_bestguidetipsandtricks;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
public class MainActivity extends AppCompatActivity {
SharedPreferences prefs;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
prefs = getSharedPreferences("myPrefs", MODE_PRIVATE);
int times = prefs.getInt("ok_clicked", 0);
if (times == 0) {
new AlertDialog.Builder(MainActivity.this).setTitle("Hi there user").setMessage("This app version right now is just 1.0 the later versions will be released soon with even more content,Images and in app video tutorials etc..and this app is completely ADD free so please do consider rating it. ").setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
prefs = getSharedPreferences("myPrefs", MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt("ok_clicked", 1);
editor.apply();
}
}).show();
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
}
public void basicsOnclick(View view) {
Intent i = new Intent(this, Basics.class);
startActivity(i);
}
public void advanceOnclick(View view) {
Intent i = new Intent(this, Advanced.class);
startActivity(i);
}
public void tipsOnclick(View view) {
Intent i = new Intent(this, Tips.class);
startActivity(i);
}
public void tricksOnclick(View view) {
Intent i = new Intent(this, Tricks.class);
startActivity(i);
}
public void resourceLinksOnclick(View view) {
Intent i = new Intent(this, Resources.class);
startActivity(i);
}
public void aboutOnclick(View view) {
new AlertDialog.Builder(MainActivity.this).setTitle("About").setMessage("App Name :Pokemon GO-Guide\nVersion :1.0 \nCreator :Prudhvi").setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).show();
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
this.finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
LogCat (It had not crashed for this log cat)-
at com.android.systemui.statusbar.SignalClusterView.apply(SignalClusterView.java:468)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.refreshViews(NetworkControllerImpl.java:1986)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.refreshViews(NetworkControllerImpl.java:1679)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.onReceive(NetworkControllerImpl.java:643)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:895)
at android.os.Handler.handleCallback(Handler.java:810)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:189)
at android.app.ActivityThread.main(ActivityThread.java:5529)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:751)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:114)
08-07 23:23:38.730 824-824/?
E/Xposed: java.lang.NoSuchMethodError: com.mediatek.systemui.ext.DefaultStatusBarPlugin#getDataNetworkTypeIconGemini(com.mediatek.systemui.ext.NetworkType,int)#exact
at de.robv.android.xposed.XposedHelpers.findMethodExact(XposedHelpers.java:170)
at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:131)
at com.ceco.lollipop.gravitybox.ModStatusBar$24.afterHookedMethod(ModStatusBar.java:1072)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:689)
at com.mediatek.systemui.ext.PluginFactory.getStatusBarPlugin(<Xposed>)
at com.android.systemui.statusbar.SignalClusterView.apply(SignalClusterView.java:401)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.refreshViews(NetworkControllerImpl.java:1986)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.refreshViews(NetworkControllerImpl.java:1679)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.onReceive(NetworkControllerImpl.java:643)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:895)
at android.os.Handler.handleCallback(Handler.java:810)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:189)
at android.app.ActivityThread.main(ActivityThread.java:5529)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:751)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:114)
08-07 23:23:38.731 824-824/?
E/Xposed: java.lang.NoSuchMethodError: com.mediatek.systemui.ext.DefaultStatusBarPlugin#getDataNetworkTypeIconGemini(com.mediatek.systemui.ext.NetworkType,int)#exact
at de.robv.android.xposed.XposedHelpers.findMethodExact(XposedHelpers.java:170)
at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:131)
at com.ceco.lollipop.gravitybox.ModStatusBar$24.afterHookedMethod(ModStatusBar.java:1072)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:689)
at com.mediatek.systemui.ext.PluginFactory.getStatusBarPlugin(<Xposed>)
at com.android.systemui.statusbar.SignalClusterView.getNullIconIdGemini(SignalClusterView.java:557)
at com.android.systemui.statusbar.SignalClusterView.apply(SignalClusterView.java:468)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.refreshViews(NetworkControllerImpl.java:1986)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.refreshViews(NetworkControllerImpl.java:1679)
at com.android.systemui.statusbar.policy.NetworkControllerImpl.onReceive(NetworkControllerImpl.java:643)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:895)
at android.os.Handler.handleCallback(Handler.java:810)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:189)
at android.app.ActivityThread.main(ActivityThread.java:5529)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:751)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:114)
i'am still beginner in android.
how to make android onclicklistener to next activity, i mean,i make RegisterActivity and when the user has register , the program should be to MainActivity but it goes to SingleMenuItemActivity. anyone can tell me what i suppose to do? thank you very much.
*sorry for my bad english.
package unai.skripsi.bandungtourgiude;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class SingleMenuItemActivity extends Activity {
// JSON node keys
private static final String in_nama_tempat = "nama_tempat";
private static final String in_alamat_tempat = "alamat_tempat";
private static final String in_no_tempat = "no_tempat";
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.single_list_item);
// getting intent data
Intent in = getIntent();
// Get JSON values from previous intent
String nama = in.getStringExtra(in_nama_tempat);
String alamat = in.getStringExtra(in_alamat_tempat);
String nomor = in.getStringExtra(in_no_tempat);
// Displaying all values on the screen
TextView lblName = (TextView) findViewById(R.id.nama_tempat);
TextView lblCost = (TextView) findViewById(R.id.alamat_tempat);
TextView lblDesc = (TextView) findViewById(R.id.no_tempat);
lblName.setText(nama);
lblCost.setText(alamat);
lblDesc.setText(nomor);
Button map = (Button) findViewById(R.id.button1);
map.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(SingleMenuItemActivity.this, Pariwisata.class));
}
});
Button call = (Button) findViewById(R.id.button2);
call.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(SingleMenuItemActivity.this, Telfon.class));
}
});
Button text = (Button) findViewById(R.id.button3);
text.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(SingleMenuItemActivity.this, RegisterActivity.class));
}
});
}
}
RegisterActivity.java
package unai.skripsi.bandungtourgiude;
import static unai.skripsi.bandungtourgiude.CommonUtilities.SENDER_ID;
import static unai.skripsi.bandungtourgiude.CommonUtilities.SERVER_URL;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class RegisterActivity extends Activity {
// alert dialog manager
AlertDialogManager alert = new AlertDialogManager();
// Internet detector
ConnectionDetector cd;
// UI elements
EditText txtName;
EditText txtEmail;
// Register button
Button btnRegister;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
cd = new ConnectionDetector(getApplicationContext());
// Check if Internet present
if (!cd.isConnectingToInternet()) {
// Internet Connection is not present
alert.showAlertDialog(RegisterActivity.this,
"Internet Connection Error",
"Please connect to working Internet connection", false);
// stop executing code by return
return;
}
// Check if GCM configuration is set
if (SERVER_URL == null || SENDER_ID == null || SERVER_URL.length() == 0
|| SENDER_ID.length() == 0) {
// GCM sernder id / server url is missing
alert.showAlertDialog(RegisterActivity.this, "Configuration Error!",
"Please set your Server URL and GCM Sender ID", false);
// stop executing code by return
return;
}
txtName = (EditText) findViewById(R.id.txtName);
txtEmail = (EditText) findViewById(R.id.txtEmail);
btnRegister = (Button) findViewById(R.id.btnRegister);
/*
* Click event on Register button
* */
btnRegister.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View arg0) {
// Read EditText dat
String name = txtName.getText().toString();
String email = txtEmail.getText().toString();
// Check if user filled the form
if(name.trim().length() > 0 && email.trim().length() > 0){
// Launch Main Activity
Intent i = new Intent(getApplicationContext(), MainActivity.class);
// Registering user on our server
// Sending registraiton details to MainActivity
i.putExtra("name", name);
i.putExtra("email", email);
startActivity(i);
finish();
}else{
// user doen't filled that data
// ask him to fill the form
alert.showAlertDialog(RegisterActivity.this, "Registration Error!", "Please enter your details", false);
}
}
});
}
}
my AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="unai.skripsi.bandungtourgiude"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="unai.skripsi.bandungtourguide.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="unai.skripsi.bandungtourguide.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Creates a custom permission so only this app can receive its messages. -->
<permission
android:name="unai.skripsi.bandungtourgiude.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="unai.skripsi.bandungtourgiude.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive data message. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- Network State Permissions to detect Internet status -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Permission to vibrate -->
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity
android:name="unai.skripsi.bandungtourgiude.DashboardActivity"
android:label="#string/app_name"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".RegisterActivity"
android:label="#string/app_name"></activity>
<!-- Main Activity -->
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden"
android:label="#string/app_name" >
</activity>
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="unai.skripsi.bandungtourgiude" />
</intent-filter>
</receiver>
<service android:name=".GCMIntentService" />
<!-- Login Activity -->
<activity
android:label="Silahkan login"
android:name=".Fungsilogin"></activity>
<!-- Register Activity -->
<activity
android:label="Silahkan mendaftar"
android:name=".Pendaftaran"></activity>
<activity
android:label="tes"
android:name=".TesAsyncTaskActivity"></activity>
<activity
android:label="PILIHAN TEMPAT"
android:name=".SingleMenuItemActivity"></activity>
<activity
android:label="rumah sakit"
android:name=".RumahSakit"></activity>
<activity
android:label="hotel"
android:name=".Hotel"></activity>
<activity
android:label="ATM"
android:name=".Atm"></activity>
<activity
android:label="PARIWISATA"
android:name=".Pariwisata"></activity>
<activity
android:label="KANTOR POLISI"
android:name=".Polisi"></activity>
<activity
android:label="KULINER"
android:name=".Kuliner"></activity>
<activity
android:label="OUTLET"
android:name=".Outlet"></activity>
<activity
android:label="OUTLET"
android:name=".Map"></activity>
<activity
android:label="rumah sakit"
android:name=".Semuatempat"></activity>
<activity
android:label="Telfon operator"
android:name=".Telfon"></activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAkJYisD9-6HB8D1asdeTTTZVtgNCLg8Fyk" />
</application>
</manifest>
Intent filter determines what gets launched.
Change your manifest as follows
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and remove
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
from Dashboard activity.
HTH.
In your btnRegister onClick listener, remove startActivity and finish.
Intent i = new Intent(getApplicationContext(), MainActivity.class);
// Registering user on our server
// Sending registraiton details to MainActivity
i.putExtra("name", name);
i.putExtra("email", email);
RegisterActivity.this.startActivity(i);
If you don't want RegisterActivity in the history stack, set attribute android:noHistory=true for the activity tag in your manifest file instead of finish() method.