Click here to Skip to main content
14,924,006 members
Home / Discussions / Android
   

Android

 
QuestionShow a ProgressDialog inside a Fragment that is injected in a Tab Pin
Vimalsoft(Pty) Ltd30-Sep-17 5:54
professionalVimalsoft(Pty) Ltd30-Sep-17 5:54 
QuestionRe: Show a ProgressDialog inside a Fragment that is injected in a Tab Pin
David Crow2-Oct-17 3:09
MemberDavid Crow2-Oct-17 3:09 
AnswerRe: Show a ProgressDialog inside a Fragment that is injected in a Tab Pin
Vimalsoft(Pty) Ltd2-Oct-17 7:11
professionalVimalsoft(Pty) Ltd2-Oct-17 7:11 
QuestionRe: Show a ProgressDialog inside a Fragment that is injected in a Tab Pin
David Crow2-Oct-17 7:14
MemberDavid Crow2-Oct-17 7:14 
AnswerRe: Show a ProgressDialog inside a Fragment that is injected in a Tab Pin
Vimalsoft(Pty) Ltd2-Oct-17 7:25
professionalVimalsoft(Pty) Ltd2-Oct-17 7:25 
QuestionRe: Show a ProgressDialog inside a Fragment that is injected in a Tab Pin
David Crow2-Oct-17 7:30
MemberDavid Crow2-Oct-17 7:30 
AnswerRe: Show a ProgressDialog inside a Fragment that is injected in a Tab Pin
Vimalsoft(Pty) Ltd2-Oct-17 7:37
professionalVimalsoft(Pty) Ltd2-Oct-17 7:37 
QuestionTiming and fragment creation Pin
David Crow29-Sep-17 7:44
MemberDavid Crow29-Sep-17 7:44 
I created a small app based on a "Tabbed Activity." It has two tabs. The content of both tabs will be a ListView filled from the Contacts database. Because of the new Permissions requirements that came out with Android 6, I need permission from the user at runtime to access that datastore. As such, I am calling checkSelfPermission() and requestPermissions() as prescribed in the docs.

If I put those calls in the activity, I get one request dialog asking for permission, and because requestPermissions() runs synchronously in a separate thread, the two fragments are allowed to finish their creation in the main thread. Once permission is granted, the activity sends both fragments a message indicating they can now populate their ListViews. This works fine, until I restart the app. Since permission has now been granted, requestPermissions() does not run, and the message that the activity sends to the fragments gets there before the fragments have been fully created. Just to see what would happen, I preceded the message with a 1-second sleep and that gave the fragments enough time to finish their creation. This works fine for both a first-time and restarted app. I did not like this approach because of the delay, so I kept looking.

If I put those calls in each fragment, I get two requests asking for permission. I can grant permission to neither, one or the other, or both, and the fragments will respond accordingly. The obvious problem is the two request dialogs. I could not find the proper way of having one fragment communicate to the other that it has already sought permission and that a second request is not necessary.

Another thing I tried was to put a call to checkSelfPermission() in each fragment's onActivityCreated() method to continuously poll the desired permission. The call to requestPermission() was still done once in the activity. Once the permission was granted, each fragment would then go about populating its ListView. This worked, but it still felt wrong given the pausing and polling each fragment was having to do.

I feel my first approach is the proper way to go, but cannot find a suitable solution to the timing issue. I found out a long time ago when doing Windows development that inserting code to slow down or speed up your program's execution is a major recipe for disaster. Better to signal events instead. So far I'm unable to find a comparable solution in either Java or Android.

Any helpful suggestions?

Thanks.
- DC

"One man's wage rise is another man's price increase." - Harold Wilson

"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles



modified 29-Sep-17 15:37pm.

QuestionAndroid.Content.ActivityNotFoundException: Unable to find explicit activity class Pin
Vimalsoft(Pty) Ltd28-Sep-17 6:43
professionalVimalsoft(Pty) Ltd28-Sep-17 6:43 
SuggestionRe: Android.Content.ActivityNotFoundException: Unable to find explicit activity class Pin
Richard MacCutchan28-Sep-17 9:44
mveRichard MacCutchan28-Sep-17 9:44 
GeneralRe: Android.Content.ActivityNotFoundException: Unable to find explicit activity class Pin
Vimalsoft(Pty) Ltd28-Sep-17 22:44
professionalVimalsoft(Pty) Ltd28-Sep-17 22:44 
GeneralHow are chat application in Android used? Pin
Salfishya Mary28-Sep-17 3:58
MemberSalfishya Mary28-Sep-17 3:58 
GeneralRe: How are chat application in Android used? Pin
Richard MacCutchan28-Sep-17 5:20
mveRichard MacCutchan28-Sep-17 5:20 
GeneralRe: How are chat application in Android used? Pin
Sienna Amelia3-Oct-17 2:07
MemberSienna Amelia3-Oct-17 2:07 
QuestionSQL server connection in Android Pin
Malashree Halade19-Sep-17 20:26
MemberMalashree Halade19-Sep-17 20:26 
AnswerRe: SQL server connection in Android Pin
Richard MacCutchan19-Sep-17 22:11
mveRichard MacCutchan19-Sep-17 22:11 
AnswerRe: SQL server connection in Android Pin
Vimalsoft(Pty) Ltd25-Sep-17 4:12
professionalVimalsoft(Pty) Ltd25-Sep-17 4:12 
QuestionAccess MySql using php script from Android app.. Pin
Member 1341654718-Sep-17 16:03
MemberMember 1341654718-Sep-17 16:03 
QuestionRe: Access MySql using php script from Android app.. Pin
David Crow19-Sep-17 9:47
MemberDavid Crow19-Sep-17 9:47 
AnswerRe: Access MySql using php script from Android app.. Pin
Member 1341654720-Sep-17 16:03
MemberMember 1341654720-Sep-17 16:03 
GeneralRe: Access MySql using php script from Android app.. Pin
Member 1341654720-Sep-17 19:24
MemberMember 1341654720-Sep-17 19:24 
SuggestionRe: Access MySql using php script from Android app.. Pin
David Crow20-Sep-17 16:52
MemberDavid Crow20-Sep-17 16:52 
GeneralRe: Access MySql using php script from Android app.. Pin
Member 1341654723-Sep-17 15:03
MemberMember 1341654723-Sep-17 15:03 
QuestionFCM notification Pin
Malashree Halade9-Sep-17 3:26
MemberMalashree Halade9-Sep-17 3:26 
AnswerRe: FCM notification Pin
David Crow9-Sep-17 4:55
MemberDavid Crow9-Sep-17 4:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.