I'm developing an android app. It receive with a push notification an URL. I need to open the url with chrome. I'm trying with this but is not working
Intent i;
try {
i = new Intent(Intent.ACTION_VIEW);
i.setType("text/html");
i.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
i.setComponent(ComponentName.unflattenFromString("com.android.chrome/com.android.chrome.Main"));
i.addCategory("android.intent.category.LAUNCHER");
i.setData(Uri.parse(audioLink));
} catch (ActivityNotFoundException ex) {
i = new Intent(Intent.ACTION_VIEW, Uri.parse(audioLink));
}
PendingIntent pendingIntent =
PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder builder;
NotificationManager manager;
manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
builder = new NotificationCompat.Builder(this)
.setContentTitle(getString(R.string.newmessagetitle))
.setContentText(getString(R.string.newmessage))
.setSmallIcon(R.mipmap.ic_stat_lollipop_icon);
builder.setContentIntent(pendingIntent);
int defaults = 0;
defaults = defaults | Notification.DEFAULT_LIGHTS;
defaults = defaults | Notification.DEFAULT_VIBRATE;
defaults = defaults | Notification.DEFAULT_SOUND;
builder.setDefaults(defaults);
builder.setAutoCancel(true);
manager.notify(notifyID, builder.build());