Android Notification With No Intent

Okay, so there may be times wherein you do not want to pass an Intent to redirect users to an app whenever the user may tap on the notification. The quickest thing that I thought might work was to pass a null Intent to the Notification object.

However, this is wrong as it can lead to problems. The correct way is to do it like this

notification.setLatestEventInfo(context, "title", "message", PendingIntent.getActivity(context, 0, new Intent(), 0));

Try it. This should do the trick.

Donations appreciated. Every little $ helps. Or click Google +1.

How To View PDF File From Android App


This helper method opens a PDF file from your Android app using any PDF related app installed in the smart phone. This is made possible with the use of an Intent object and setting its data and type so that it will recognize that it will be opening a PDF file.

If there is more than one app that can open PDF files, it will prompt you to choose which one you want to use to open the PDF file.

public static void openPdf(Context context, String filename) {
    File targetFile = new File(filname);
    Uri targetUri = Uri.fromFile(targetFile);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(targetUri, "application/pdf");
    context.startActivity(intent);
}

Donations appreciated. Every little $ helps. Or click Google +1.

Call The Compose SMS Form In Android

Here is a method that returns an Intent object reference in order for Android to open up the compose SMS form.

public static Intent textNumber(String txtnumber) {
    return new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + txtnumber));
}
 
then just call context.startActivity(textNumber("your_number"));

Donations appreciated. Every little $ helps. Or click Google +1.

Related Posts Plugin for WordPress, Blogger...