then I make a notification and add a action-button, yes and no, in the notification.
When I click on the Yes : i want to make a email-intent, using standard Email.
When I click on the no : i want to go to home screen (not to open app..).
but I cant get it to work :-(
when i click on yes or no, the app crash "in the background" and the notification "do nothing in response".
my code snippet:
first the FirebasemessagingService
then the clickerOnNotify (that to do when I click on button):
and then the Appconstant for the clicker
in manifest
;-(
Niklas Karlsson wrote:Hi I have a intent from a server (#Firebase), that only send: "do you want to mail me?"
then I make a notification and add a action-button, yes and no, in the notification.
When I click on the Yes : i want to make a email-intent, using standard Email.
When I click on the no : i want to go to home screen (not to open app..).
but I cant get it to work :-(
when i click on yes or no, the app crash "in the background" and the notification "do nothing in response".
my code snippet:
first the FirebasemessagingService
then the clickerOnNotify (that to do when I click on button):
and then the Appconstant for the clicker
in manifest
;-(
#Firebase
Niklas Karlsson wrote:
Brian Tkatch wrote:Have you tried debugging to see where the button fails?
thank you for your answer,
the strange thing is that I cant demo on a virDevice this ang my mobil do nit work anymore with the USB interface to the PC so i build the apk and install this everytime now :-(
Ouch! That points to larger problems though. But even if it didn't, you really need to be able to debug. Personally, i found this works really well on a laptop with Ubuntu and Studio.
Brian Tkatch wrote:
Niklas Karlsson wrote:
Brian Tkatch wrote:Have you tried debugging to see where the button fails?
thank you for your answer,
the strange thing is that I cant demo on a virDevice this ang my mobil do nit work anymore with the USB interface to the PC so i build the apk and install this everytime now :-(
Ouch! That points to larger problems though. But even if it didn't, you really need to be able to debug. Personally, i found this works really well on a laptop with Ubuntu and Studio.
Yes I know, I went from Eclipse to AS, and then the problem begun... :-(
Niklas Karlsson wrote:Yes I know, I went from Eclipse to AS, and then the problem begun... :-(
Try a fresh install. AS works really well; slow on some computers, fast on others. But, considering how integral it will be to your development process, i would suggest getting it to work. If the system is messed up and you cannot reinstall it, try a virtual machine.
Niklas Karlsson wrote:I think it is a problem some how with the intent and that i cant make a intent in a non application (?)
I do not know enough to answer that question. I would setup a small test case if i wasn't sure about something.
public class clickerOnNotify extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String to = "ser@ser.com";
String subject = "subject";
String message = "textMessage";
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});
//email.putExtra(Intent.EXTRA_CC, new String[]{ to});
//email.putExtra(Intent.EXTRA_BCC, new String[]{to});
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
//need this to prompts email client only
email.setType("message/rfc822");
context.startActivity(Intent.createChooser(email, "Choose an Email client :"));
}
}

Before the broadcast receiver is tested, you must make sure the broadcast is being made. Then, have the receiver write to a file or popup a toast message to verify it received the message, before worrying how it is going to start an activity.
Context gets pretty strange when control is passed around. I played with something similar once and it took me a bit to get it straight.
Niklas Karlsson wrote:
Niklas Karlsson wrote:I think it is a problem some how with the intent and that i cant make a intent in a non application (?)
YES, the broadcarreciver recive the "buttonpress.."
but i beleave it is the "sent mail in the broadcastR.." that is the problem..
I would try the email sending code outside of a broadcast receiver, to rule out it causing the issue.
Brian Tkatch wrote:Please post all code inside of code blocks. It makes it so much easier to read.
![]()
Before the broadcast receiver is tested, you must make sure the broadcast is being made. Then, have the receiver write to a file or popup a toast message to verify it received the message, before worrying how it is going to start an activity.
Context gets pretty strange when control is passed around. I played with something similar once and it took me a bit to get it straight.
thew code that dont work is the one in the Broadcast Reviser:
is :context.startActivity(Intent.createChooser(intent, "chose E-client:"));
the issue?
Niklas Karlsson wrote:
Brian Tkatch wrote:Please post all code inside of code blocks. It makes it so much easier to read.
![]()
Before the broadcast receiver is tested, you must make sure the broadcast is being made. Then, have the receiver write to a file or popup a toast message to verify it received the message, before worrying how it is going to start an activity.
Context gets pretty strange when control is passed around. I played with something similar once and it took me a bit to get it straight.
thew code that dont work is the one in the Broadcast Reviser:
is :context.startActivity(Intent.createChooser(intent, "chose E-client:"));
the issue?
That is beyond what i know, sorry.

I hope someone else can try to help.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |