android-activity

Android implementation of lifecycle methods can call the superclass implementation after doing any work?

江枫思渺然 提交于 2020-02-12 08:37:35
问题 In the Android documentation we have: Note: Your implementation of these lifecycle methods must always call the superclass implementation before doing any work... But I have seen cases where the code is placed after the superclass method, especially for methods like onPause(), onStop(), onDestroy(), for example: @Override protected void onPause() { LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver); super.onPause(); } http://www.vogella.com/articles

Android implementation of lifecycle methods can call the superclass implementation after doing any work?

烂漫一生 提交于 2020-02-12 08:37:06
问题 In the Android documentation we have: Note: Your implementation of these lifecycle methods must always call the superclass implementation before doing any work... But I have seen cases where the code is placed after the superclass method, especially for methods like onPause(), onStop(), onDestroy(), for example: @Override protected void onPause() { LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver); super.onPause(); } http://www.vogella.com/articles

Android monkey test choose a specific activity

﹥>﹥吖頭↗ 提交于 2020-02-11 05:40:27
问题 I'm using the Android monkey test to test my android apps, it's works for my app, and is very cool. but I'd like to test an application activity in specific, how could i do that? today I'm testing all app with: $ adb shell monkey -p my.package -c android.intent.category.HOME -c android.intent.category.DEFAULT -v 500 -s "a random number" 回答1: With Android monkey test i cannot test a specific activity, but with Android monkey runner i can do python scripts to simulate a monkey test, so i did a

Close all running activities in an android application?

南笙酒味 提交于 2020-02-10 15:16:05
问题 I create one application and never use finish() for each activity. If my user clicks on the logout button it goes to the previous page. How can I close my previous activity and close the application? 回答1: This is one workaround that i have tried and it worked for me perfectly. SOLUTION-1 this.finish();//try activityname.finish instead of this Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity

How can I fix my audio? (Prioritize)

半城伤御伤魂 提交于 2020-02-08 01:29:26
问题 When two audio's are played at the same time...the sound is canceling out. How do I fix this weird phenomenon? I have some code where there is audio on button click and audio in ten second intervals (in a background service). I have the following code to stop the button audio when the ten second interval plays, and it works fine: public static void myPop(Context context){ AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); if(!manager.isMusicActive()) { /

android - how to delay an audio file by a few seconds

强颜欢笑 提交于 2020-02-07 08:57:25
问题 I'm trying to figure out how to delay an audio file by about 15 seconds. The audio file is 5 seconds long and it's a sound effect saying "5,4,3,2,1 go!", the countdown is from 20 so it should start after 15 seconds. I heard I can do this with a handler but I don't know how to implement it in the code, so here it is, help would be much appreciated! I edited it with the way below, however now the player doesn't start at all, here's the new code: public class WorkoutGymEasy1 extends Activity {

Activity is closed after onActivityResult is called

做~自己de王妃 提交于 2020-02-06 05:43:09
问题 Activity Explanation: Activity_A ... nfc activity that gets started when tag is read Activity_B ... activity to capture user signature Hi, my problem goes like that: I have Activity_A and in that activity I call Activity_B with startActivityForResult() method. I then do some work in Activity_B and close it. After that method onActivityResult() is called in my Activity_A. I handle the returned data and all is great, but Activity_A is no longer visible. If I close Activity_B with back button,

Final variable from resources file

為{幸葍}努か 提交于 2020-02-03 09:57:55
问题 I have an activity with some final variables. I extracted their values (let's assume they're all Strings) into a resources file. The problem: If I directly assign them on the instantiation (as following): private final String PREFERENCE_NAME = getResources().getString(R.string.preference_name); I get the following error: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference

Final variable from resources file

烂漫一生 提交于 2020-02-03 09:55:06
问题 I have an activity with some final variables. I extracted their values (let's assume they're all Strings) into a resources file. The problem: If I directly assign them on the instantiation (as following): private final String PREFERENCE_NAME = getResources().getString(R.string.preference_name); I get the following error: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference

Possibility for Fake NFC(Near Field Communication) Launch

荒凉一梦 提交于 2020-02-02 03:19:30
问题 I am working on Near Field Communication for reading data from NFC Tags. I don't have NFC supported Android Mobile and NFC Tags to test the Application i created . I want to know whether it is possible to Launch my App through intent filter (Should assume NFC tag is detected from my device) My Manifest Snippet : <activity android:name=".ServerActivity" android:label="@string/app_name" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.nfc.action.NDEF