android-activity

Android DexClassLoader error, 'optimized data directory .. not owned by current user'

ぃ、小莉子 提交于 2019-12-30 11:20:50
问题 I am trying to produce a simple android application that can load a DEX file from the SD card at run-time. The application has two activites. The first activity is a simple screen that has a button. When the button is pressed, the second activity is launched which causes the loadDex() method to be invoked. The loadDex() method attempts to locate a jar file on the SD card and load it into the current application. Here is my code for the first activity: package poc.example.del.customclass;

Showing flashing LED for foreground activity / screen on

百般思念 提交于 2019-12-30 10:53:39
问题 I'm trying to turn the LED-flashing on for my activity in foreground, but it works only when the screen is off. Is it possible to turn the LED on for active activity with the screen on? My code: protected void led() { Notification notif = new Notification(); notif.ledARGB = 0xFF0000ff; notif.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_ONGOING_EVENT; notif.ledOnMS = 800; notif.ledOffMS = 200; notificationManager.notify( LED_NOTIFICATION_ID, notif ); } 回答1: At first Android LED

Android Activity Flow (Login or Register and go to Home)

若如初见. 提交于 2019-12-30 10:53:06
问题 I am building an application which requires user authentication. First time a user opens the app should login or register to continue to the home screen of the app which loads some posts.. i should mention that the home screen should be a FragmentActivity to allow user navigate between 2-3 tabs.. this means that i should have another Activity (for the login screen or register) to allow the user to continue later to home. MainActivity | | --> Check If user logged in | | | | | --> Start Login

Call Activity Method From Fragment

限于喜欢 提交于 2019-12-30 10:34:16
问题 I'm dealing with fragments. I have an Activity and different fragments . Each fragment need the access to a Class(call it X) that allow it to access a database, but, because I have a lot of fragments, I don't want to create a different instance of the Class X in every fragment as I think it will require lots of memory . So how can I do? I wrote something like this (with a getter), but it doesn't work! public class MyActivity { private ClassX classx; ..... public ClassX getClassX() { return

Defining android activity as dialog with light theme

北战南征 提交于 2019-12-30 10:08:25
问题 In my application I am defining one android activity as dialog.It looks proper.Only problem with that is my dialog appear in dark theme. I want to display it into light theme. I defined my activity dialog in following manner : <activity android:theme="@android:style/Theme.DeviceDefault.Dialog.MinWidth" android:name="com.example.dialog" android:label="@string/title_activity_list" > </activity> How to do this. Any solution. Need Help. Thank you. 回答1: You need to use Holo Light Dialog theme:

why “onPause” is not called in following situation?

断了今生、忘了曾经 提交于 2019-12-30 09:40:35
问题 By the document, "onPause" is called, when: when the system is about to start resuming a previous activity. Compared to "onStop", the difference is: Called when the activity is no longer visible to the user, because another activity has been resumed and is covering this one. But when I long-press HW-Home key and the "recent apps" shows up, the "onPause" is not called. At this moment, I can no long able to interact with the original activity, but it is still visible. I am confused by this

Maximum amount of activities in app? Android

六眼飞鱼酱① 提交于 2019-12-30 09:36:43
问题 Is there something like maximum activities in android app? I would like to know because I am thinking to create sound app with ringtone feature. It will have roughly around 40 activities. But only 1 will be running constantly. Is that too much? Should I find another way? Explanation why I need 40 activities I have 30 sounds and I want to set them as ringtone. 1 normal activity with buttons to play Mp and stuff, and 35 other activities, 1 for each file. What I want is to on Long click start

How to pass an array of Uri between Activity using Bundle

[亡魂溺海] 提交于 2019-12-30 09:33:49
问题 I need to pass an array of Uri to another activity, to pass an array of String I use simply String[] images=getImagesPathString(); Bundle b = new Bundle(); b.putStringArray("images", images); But using an array of Uri Uri[] imagesUri=getImagesUri(); this doesn't works because there isn't a method "putUri(Uri x)" in Bundle How could I solve this problem? 回答1: You should look into the Parcelable interface to see how to pass things on an intent http://developer.android.com/intl/es/reference

how to check if activity is still in the stack?

孤街浪徒 提交于 2019-12-30 08:58:08
问题 what is the better way to check if the activity is still in the stack in order to call it back ? Intent i = new Intent(getApplicationContext(),MyClass.class); startActivity(i); 回答1: Look at the ActivityManager API To get an instance of the ActivityManager use this code: ActivityManager mngr = (ActivityManager) getSystemService( ACTIVITY_SERVICE ); 回答2: I am surprised how unpopular this (kind of) question(s) is. Let me start from the solution first: Since ActivityManager.getRunningTasks is

How to get all Views in an Activity?

时间秒杀一切 提交于 2019-12-30 08:08:32
问题 is there a way to get every view that is inside my activity? I have over 200 views including buttons, and images, so i want to be able to access them by using a loop for example something like for (View v : this) { //do something with the views //depending on the types (button, image , etc) } 回答1: is there a way to get every view that is inside my activity? Get your root View , cast it to a ViewGroup , call getChildCount() and getChildAt() , and recurse as needed. I have over 200 views