How can I do something similar to Telegram and many other apps, which allow you to add an element in this case by telegram is a contact that if clicked on it opens the contact chat window.
I would like to do something like this, adding an element to the home if you click on it, allows you to do a certain operation.
But I have to open an app external to mine.
Edit:
Intent which must be called when clicking on the link on the homescreen, str name connection element.
Intent appIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://instagram.com/_u/"+str));
appIntent.setPackage("com.instagram.android");
Intent webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://instagram.com/"+str));
try {
startActivity(appIntent);
} catch (ActivityNotFoundException ex) {
startActivity(webIntent);
}
Edit2:
add:
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
code:
if (ShortcutManagerCompat.isRequestPinShortcutSupported(getBaseContext())) {
Intent instagramIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://instagram.com/_u/" + str));
instagramIntent.setPackage("com.instagram.android");
Bitmap bmp = getCroppedBitmap(bitmap);
final IconCompat icon = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) ? IconCompat.createWithAdaptiveBitmap(bmp) : IconCompat.createWithBitmap(bmp);
final ShortcutInfoCompat shortcut = new ShortcutInfoCompat.Builder(getBaseContext(), UUID.randomUUID().toString())
.setShortLabel(str)
.setLongLabel(str)
.setIcon(icon)
.setIntent(instagramIntent)
.build();
ShortcutManagerCompat.requestPinShortcut(getBaseContext(), shortcut, null);
}