Skip to content

Instantly share code, notes, and snippets.

@michaeltys
michaeltys / ShareFileToInstagram
Created October 10, 2018 15:13
Sharing an image to instagram stories or create a post
private void shareFileToInstagram(Uri uri, boolean isVideo, Post post) {
Intent feedIntent = new Intent(Intent.ACTION_SEND);
feedIntent.setType(isVideo ? "video/*" : "image/*");
feedIntent.putExtra(Intent.EXTRA_STREAM, uri);
feedIntent.setPackage(Constants.INSTAGRAM_PACKAGE_NAME);
Intent storiesIntent = new Intent("com.instagram.share.ADD_TO_STORY");
storiesIntent.setDataAndType(uri, isVideo ? "mp4" : "jpg");
storiesIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
storiesIntent.setPackage(Constants.INSTAGRAM_PACKAGE_NAME);
@michaeltys
michaeltys / AndroidNotificationHelper
Created October 10, 2018 15:11
Showing high importance notifications on different android OS versions
public void showNotification(String message, PendingIntent pendingIntent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createNotificationChannel();
}
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, "")
.setSmallIcon(R.drawable.ic_icon)
.setColor(ContextCompat.getColor(getApplicationContext(), R.color.color_primary_blue))
.setContentTitle(getString(R.string.app_name))
.setContentText(message)