[Solved] Finishing activities A & B from activity B and go to activity C in android

The better solution is, you should replace startActivity() with startActivityForResult() for activity transition. And from logout userActivity you just set a result and you will get onActivityResult in your mainActivity if you handle it properly.Then you can simply finish mainActivity. Refer https://developer.android.com/training/basics/intents/result.html Another way is finish MainActivity from its onResume, if the activity onResume is … Read more

[Solved] I have around 1000 different activities in my Android App. How can I jump to a random activity?

Although this is terrible, I’ll still show a possible way to do this. But just remember, this is TERRIBLE. You can store all the activity classes in an ArrayList. ArrayList<Class<Activity>> activities = new ArrayList<> (); And then you add all the activities into the ArrayList. Yeah, I know, this part is tedious. For example, activities.add … Read more

[Solved] Does the Activity need to be Serializable when sending a class that implements Serializable through Intent and putExtra?

Does i.putExtra(String name, Serializable s) require the Activity where the Intent is sent from to implement Serializable? No, but it does mean that s cannot refer to the activity or other non-Serializable stuff or you will need to take steps to prevent the serialization from trying to serialize them (e.g., override the methods described in … Read more

[Solved] Activity not reading intent from other class in Android SDK

You need to define that constant in MainActivity as public static final String EXTRA_MESSAGE = “extra_message”; so that in DisplayMessageActivity you can access that static constant as String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE); MainActivity public class MainActivity extends AppCompatActivity { public static final String EXTRA_MESSAGE = “extra_message”; // static : accessed by class name // final : … Read more

[Solved] StartActivityforResult brackets meaning [closed]

public void startActivityForResult (Intent intent, int requestCode) Added in API level 1 Same as calling startActivityForResult(Intent, int, Bundle) with no options. Parameters intent The intent to start. requestCode If >= 0, this code will be returned in onActivityResult() when the activity exits. Quoted from Android Developers. It’s like a reply for the calling method. 1 … Read more

[Solved] How to handle a large number of activities in android studio

No, you don’t need that many activities. You need to write abstract activities that take parameters and displays different data based on those. At most I see 4 activities here- department selector, semester selector, subject selector, and the actual subject activity. And arguably some of those should be fragments instead, although that’s more personal choice. … Read more

[Solved] Unfortunately, (App Name) has stopped [closed]

http://developer.android.com/reference/android/content/Context.html#getSystemService(java.lang.String) getSystemService needs a context. So change your code as below Context context; public CustomlistActivity( Context context, int resource, int textViewResourceId, ArrayList<Item> string) { super(context, resource, textViewResourceId, string); // TODO Auto-generated constructor stub strings = string; this.context = context; } Then LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); and remove private LayoutInflater getSystemService(String layoutInflaterService) { // TODO Auto-generated … Read more

[Solved] Wondering why my app crashes

Looking at your code it seems that you made a typo here: TextView DialogText=(TextView) findViewById(R.id.imageViewDialog); It should be TextView DialogText=(TextView) findViewById(R.id.textViewDialog); or whatever the name of the id for this TextView is. Apart from that, you need to learn to read the messages from the LogCat as they are often very informative. Cleary it says: … Read more

[Solved] calling an activity from fragment activity through Intent [closed]

the Intent constructor accepts two arguments. first argument is your Context and the second one is your Activity class. in your fragment, you can access your Context via getActivity method. here is what you should do : Intent i = new Intent(getActivity(), MyActivity.class); 0 solved calling an activity from fragment activity through Intent [closed]

[Solved] Android: Starting Alarm Service from Dialog

Your code based on Android Dev Guide is working, to be more precise, this one: alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, AlarmReceiver.class); PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0); alarmMgr.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime() + 10 * 1000, alarmIntent); Alarm.Receiver.java: public class AlarmReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { /* class1 = … Read more

[Solved] intent in alart dialog [closed]

you need to use activity or context, for example, please refer below code AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(activity) .setCancelable(false) .setPositiveButton(“Ok”, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { activity.startActivity(new Intent(activity, DetailView.class)); } }).setNegativeButton(“Cancel”, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); you can … Read more