|
It means, do not say "I want ...". Explain your problem in proper detail. If you want someone else to write the code for you then employ a programmer.
|
|
|
|
|
See here.
"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
|
|
|
|
|
I had used the above code in my code but didn't anything work.
|
|
|
|
|
pankaj788 wrote: I had used the above code in my code but didn't anything work. Well, without seeing your exact code that did not work, it's impossible to know. Regardless, posting the same question more than once will not solve anything either.
"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
|
|
|
|
|
You can store your spinner data into Arraylist and aftetr that this whole Arraylist can store in sharedprefrence.
|
|
|
|
|
Hi...
I want to do a task in android... If i enter the date of birth in a edittext then age should be calculated and if i enter the age in edittext then birth year should be calculated automatically.. This must be done without using buttons... How to do.. Help me.
|
|
|
|
|
|
This sounds like a bad UI in the making. For example, if you wanted to enter the birth year 2003 and got the 20 entered, how would your code know that it was part of the birth year and not the age? Listening for each letter typed and trying to figure out the user's intent is not always possible and leaves room for misinterpretation.
sabareeswara wrote: This must be done without using buttons Why?
"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
|
|
|
|
|
Put your logic in afterTextChange with help of onTextChaneListener.
|
|
|
|
|
How can we display the pop up message of some activity? but that activity must have in onPause() state.
OR
How to display the pop up message of activity in our front screen, smiler like flash message had been displayed on our front screen. But activity must have in onPause() mode.
|
|
|
|
|
|
Any other method except Toast. Because toast doesn't have close or OK button like pop up message box.
|
|
|
|
|
In that case use a Dialog[^]. But in future you should provide a bit more detail to your questions.
|
|
|
|
|
pankaj788 wrote: How can we display the pop up message of some activity? but that activity must have in onPause() state. What does implementing the onPause() method have to do with displaying a message?
pankaj788 wrote: ...smiler like flash message had been displayed on our front screen. What is a "flash message?"
"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
|
|
|
|
|
How save spinner data using sharedPreferences and How that data load in that spinner after reopening of the activity?
|
|
|
|
|
pankaj788 wrote: How save spinner data using sharedPreferences... Assuming you already have the data from the spinner, try:
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
Editor editor = prefs.edit();
editor.putString(key, value_obtained_from_spinner);
editor.commit();
pankaj788 wrote: ...How that data load in that spinner after reopening of the activity? In onCreate() , onStart() , or onResume() , you'll need something like:
String value = prefs.getString(key);
int pos = adapter_tied_to_spinner.getPosition(value);
spinner.setSelection(pos);
"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
|
|
|
|
|
I have used the above code in my activity but nothing append anything.
Can you give me the activity? Cause I am new in Android.
And
What is "key, value_obtained_from_spinner"? Cause I have created the the spinner programmatically.
modified 18-Feb-15 12:21pm.
|
|
|
|
|
pankaj788 wrote: Can you give me the activity? I don't have an activity. I just pulled that code off the top of my head.
pankaj788 wrote: What is "key, value_obtained_from_spinner"? See here.
pankaj788 wrote: Cause I have created the the spinner programmatically. Any reason why?
"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
|
|
|
|
|
I have seen multiple solutions to let a Service / Activity communicate each other. However I can't understand in which context we should use them and why.
From what I've read around (android documentation and stackoverflow), these are the main approaches:
- Bind to the service using bindService()
- Use a messenger (it should be for IPC, but somebody uses it for same process communication)
- Static instance (singleton) of the Service. This method could bring errors, what happens if the service dies? Null reference of that service. Shouldn't be better the first approach then this one?
- Use LocalBroadcastManager and register the Activity for receiving. Basically, the Activity listen to the broadcasts sent by the Service. Viceversa, the Service in its onStartCommand dispatch intent actions sent from the Activity (explicit intent with custom action). For dispatching actions in the service, another solution could be intent filters on the service and implicit intents (android documentation says NO in the notes, even if I declare custom actions). How many chances are that someone else uses the same custom actions as mine?
- Otto API
Now I'm really confused. Could somebody explain (if possible with examples) why and in which context we should use those approaches?
Are there other solutions other than the ones in this list?
Thank you.
modified 13-Feb-15 10:51am.
|
|
|
|
|
I have and app which requires sending emails with attachments.
This app contains many activities. Within one activity, I send an email using the following intent:
startActivityForResult(Intent.createChooser(emailIntent, "Email"), EMAIL_REQUEST);
This works fine. The email is sent.
The problem:
After email is sent, the app loads/goes to the startup activity, not the activity from which the email was sent.
(Also note: onActivityResult is never called)
How can I return to the activity which sent the email?
Code fragment:
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{to});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT, message);
emailIntent.setType("message/rfc822");
File publicFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File inFile = new File(publicFolder, "snapshot.PNG");
if (inFile.exists() && inFile.canRead()) {
Uri uri = Uri.fromFile(inFile);
emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
try { startActivityForResult(Intent.createChooser(emailIntent, "Choose an Email client :"), EMAIL_REQUEST);
isSuccess = true;
}
catch (Exception e) {
Toast.makeText(getApplicationContext(), "startActivity() exception thrown while sending email", Toast.LENGTH_SHORT).show();
}
}
modified 13-Feb-15 11:19am.
|
|
|
|
|
You need to edit your question and show a bit more of the code and indicate exactly where the problem occurs. Please ensure that you use <pre lang="java"></pre> tags around your code, so it is readable like:
startActivityForResult(Intent.createChooser(emailIntent, "Email"), EMAIL_REQUEST);
|
|
|
|
|
What are you doing in the onActivityResult() method?
"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
|
|
|
|
|
I have found a solution.
The initial activity's onresume method is called after the email is sent. What I do is intercept it and perform a startactivity to load the activity which was responsible for sending the email.
|
|
|
|
|
Without further investigation, that sounds more like a workaround than a solution. I have an app that sends an email, and it requires no special code to return right where it was prior to sending the email.
Unless your app is doing something at the same time the email is being composed/sent, have you tried using startActivity() instead of startActivityForResult() ?
"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
|
|
|
|
|
yes, I did try startActivity. Same effect.
|
|
|
|