android-activity

How to find last activity from which current activity is opened in android?

被刻印的时光 ゝ 提交于 2019-12-28 05:35:47
问题 I have one activity which can be open from more 4 or 5 different activity so i can find from which activity my current activity is called... If any idea please help me.. 回答1: You might want to add extras to the intent you use to start the activity to indicate where the intent is coming from or what the request is. For example: Intent intent = new Intent(this, OtherActivity.class); intent.putExtra("caller", "MainActivity"); startActivity(intent); and then your OtherActivity could detect the

Get Activity name dynamically - android

陌路散爱 提交于 2019-12-28 05:06:34
问题 I'd like to get the name of the current Activity to be sent along in the URI of an HttpRequest . Is there a way to do this without referring specifically to the Activity ? I know I can do myActivity.class.toString() but this is just a less efficient way of hard coding "myActivity" since I'm making a static reference to my Activity . Is there a more general way to do this using something like 'this' (which btw doesn't actually work here because it returns more information than what's desired).

Get Activity name dynamically - android

不想你离开。 提交于 2019-12-28 05:06:12
问题 I'd like to get the name of the current Activity to be sent along in the URI of an HttpRequest . Is there a way to do this without referring specifically to the Activity ? I know I can do myActivity.class.toString() but this is just a less efficient way of hard coding "myActivity" since I'm making a static reference to my Activity . Is there a more general way to do this using something like 'this' (which btw doesn't actually work here because it returns more information than what's desired).

The activity must be exported or contain an intent-filter

蹲街弑〆低调 提交于 2019-12-28 03:48:07
问题 when I tried to run my application its show the error below Error running Dashboard: The activity must be exported or contain an intent-filter How can I solve this error? 回答1: I changed the Select Run/Debug Configuration from my MainActivity to App and it started working. Select App configuration snapshot: 回答2: Double check your manifest, your first activity should have tag <intent-filter> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> inside of activity tag. If

Android change layout dynamically

自作多情 提交于 2019-12-28 03:38:50
问题 I have situation where I want to change layout of activity after 3 seconds. Ho can I do that? For example application starts with splashscreen that will run for 3 seconds then automatically switch layout to application's first screen layout. This should happen in the same activity, any ideas? Thanks 回答1: I did this using only one xml layout. I just put an extra RelativeLayout in it that represents my intro screen then I use a fadeOut Animation on it and then call .setVisibility(View.GONE).

Simulate killing of activity in emulator

北城余情 提交于 2019-12-28 02:44:10
问题 I would like to test out onSaveInstanceState and onRestoreInstanceState for my app on the emulator. I have found this, which says that we could simulate this during orientation change, but I'm storing some of my variables on the application level (subclass android.app.Application ), so the orientation change does not wipe out the variables. So my question is, how can I simulate the low memory situation thus killing of my activities? Hope I've made myself clear. Thanks 回答1: You can pause your

android.app.Application cannot be cast to android.app.Activity

浪尽此生 提交于 2019-12-27 22:07:26
问题 I'm trying to change a LinearLayout from another class, but when i run this code: public class IRC extends PircBot { ArrayList<String> channels; ArrayList<Integer> userCount; ArrayList<String> topics; LinearLayout channelLayout; Context context; public IRC(Context ctx) { this.setName("xxxx"); channels = new ArrayList<String>(); userCount = new ArrayList<Integer>(); topics = new ArrayList<String>(); context = ctx; channelLayout = (LinearLayout) ((Activity) context).findViewById(R.id.channels);

android.app.Application cannot be cast to android.app.Activity

天大地大妈咪最大 提交于 2019-12-27 22:06:10
问题 I'm trying to change a LinearLayout from another class, but when i run this code: public class IRC extends PircBot { ArrayList<String> channels; ArrayList<Integer> userCount; ArrayList<String> topics; LinearLayout channelLayout; Context context; public IRC(Context ctx) { this.setName("xxxx"); channels = new ArrayList<String>(); userCount = new ArrayList<Integer>(); topics = new ArrayList<String>(); context = ctx; channelLayout = (LinearLayout) ((Activity) context).findViewById(R.id.channels);

How to listen for preference changes within a PreferenceFragment?

半城伤御伤魂 提交于 2019-12-27 18:22:10
问题 As described here, I am subclassing PreferenceFragment and displaying it inside an Activity. That document explains how to listen for preference changes here, but only if you subclass PreferenceActivity. Since I'm not doing that, how do I listen for preference changes? I've tried implementing OnSharedPreferenceChangeListener in my PreferenceFragment but it does not seem to work ( onSharedPreferenceChanged never seems to get called). This is my code so far: SettingsActivity.java public class

How to listen for preference changes within a PreferenceFragment?

让人想犯罪 __ 提交于 2019-12-27 18:22:09
问题 As described here, I am subclassing PreferenceFragment and displaying it inside an Activity. That document explains how to listen for preference changes here, but only if you subclass PreferenceActivity. Since I'm not doing that, how do I listen for preference changes? I've tried implementing OnSharedPreferenceChangeListener in my PreferenceFragment but it does not seem to work ( onSharedPreferenceChanged never seems to get called). This is my code so far: SettingsActivity.java public class