android-activity

How to check if the current activity has a dialog in front?

☆樱花仙子☆ 提交于 2020-12-28 13:50:21
问题 I am using a third-party library and sometimes it pops up a dialog. Before I finish the current activity, I want to check whether there is a dialog popped up in the current context. Is there any API for this? 回答1: You can check it running over the active fragments of that activity and checking if one of them is DialogFragment, meaning that there's a active dialog on the screen: public static boolean hasOpenedDialogs(FragmentActivity activity) { List<Fragment> fragments = activity

How to check if the current activity has a dialog in front?

泪湿孤枕 提交于 2020-12-28 13:48:42
问题 I am using a third-party library and sometimes it pops up a dialog. Before I finish the current activity, I want to check whether there is a dialog popped up in the current context. Is there any API for this? 回答1: You can check it running over the active fragments of that activity and checking if one of them is DialogFragment, meaning that there's a active dialog on the screen: public static boolean hasOpenedDialogs(FragmentActivity activity) { List<Fragment> fragments = activity

Best practices for Android Unit Testing?

家住魔仙堡 提交于 2020-12-28 06:51:28
问题 I am developing a mobile android app. What are the most common libraries/frameworks used for Android unit testing? I feel that most of the business logic, database testing, Web services testing can all be done using JUnit. However, what's the best approach for testing UI, the UI workflow, etc? For example, how can we test if the Android app launches a web browser successfully? Or how can we confirm if buttons, certain things are pressed successfully? Or if images are loaded successfully? 回答1:

Best practices for Android Unit Testing?

你。 提交于 2020-12-28 06:50:28
问题 I am developing a mobile android app. What are the most common libraries/frameworks used for Android unit testing? I feel that most of the business logic, database testing, Web services testing can all be done using JUnit. However, what's the best approach for testing UI, the UI workflow, etc? For example, how can we test if the Android app launches a web browser successfully? Or how can we confirm if buttons, certain things are pressed successfully? Or if images are loaded successfully? 回答1:

Android. Get string resource for a non-activity class [duplicate]

拈花ヽ惹草 提交于 2020-12-25 04:50:31
问题 This question already has answers here : How can I get a resource content from a static context? (14 answers) Closed 4 years ago . I have a String resource: strings.xml <resources> <string name="myString">stringName</string> </resources> How do I get the String from a non-activity-class? I can't do getResources().getString(R.string.myString) 回答1: You have to use reference to a Context to access resources. I'd recommend extending the Application class and creating an Application Singleton,

Android. Get string resource for a non-activity class [duplicate]

。_饼干妹妹 提交于 2020-12-25 04:50:09
问题 This question already has answers here : How can I get a resource content from a static context? (14 answers) Closed 4 years ago . I have a String resource: strings.xml <resources> <string name="myString">stringName</string> </resources> How do I get the String from a non-activity-class? I can't do getResources().getString(R.string.myString) 回答1: You have to use reference to a Context to access resources. I'd recommend extending the Application class and creating an Application Singleton,

OnActivityResult method is deprecated, what is the alternative?

帅比萌擦擦* 提交于 2020-12-25 01:47:47
问题 Recently I faced the onActivtyResult is deprecated . what should we do for handle it? any alternative introduced for that? 回答1: A basic training is available at developer.android.com. Here is an example on how to convert the existing code with the new one: The old way: public void openSomeActivityForResult() { Intent intent = new Intent(this, SomeActivity.class); startActivityForResult(intent, 123); } @Override protected void onActivityResult (int requestCode, int resultCode, Intent data) {

OnActivityResult method is deprecated, what is the alternative?

只愿长相守 提交于 2020-12-25 01:45:14
问题 Recently I faced the onActivtyResult is deprecated . what should we do for handle it? any alternative introduced for that? 回答1: A basic training is available at developer.android.com. Here is an example on how to convert the existing code with the new one: The old way: public void openSomeActivityForResult() { Intent intent = new Intent(this, SomeActivity.class); startActivityForResult(intent, 123); } @Override protected void onActivityResult (int requestCode, int resultCode, Intent data) {

OnActivityResult method is deprecated, what is the alternative?

走远了吗. 提交于 2020-12-25 01:40:21
问题 Recently I faced the onActivtyResult is deprecated . what should we do for handle it? any alternative introduced for that? 回答1: A basic training is available at developer.android.com. Here is an example on how to convert the existing code with the new one: The old way: public void openSomeActivityForResult() { Intent intent = new Intent(this, SomeActivity.class); startActivityForResult(intent, 123); } @Override protected void onActivityResult (int requestCode, int resultCode, Intent data) {

Android Activity::onCreate called before Application.onCreate

ぐ巨炮叔叔 提交于 2020-12-15 05:23:24
问题 In some cases I can see that Activity.onCreate is called before the Appication object gets created (before Application.onCreate is called). Is that ever possible? 回答1: May be you forgot to add your application class in manifest file. Place your application class in AndroidManifest.xml class under <application> tag. i.e., <application android:name=".{YourApplicationClassName}" ... ... 回答2: In some cases I can see that Activity.onCreate is called before the Appication object gets created