Skip to content

Instantly share code, notes, and snippets.

//Pre-Oreo
private void addShortcut(String path1, String pdfName) {
File file = new File(path1);
if (file.exists()) {
Uri path = Uri.fromFile(file);
Intent shortcutIntent = new Intent(Intent.ACTION_VIEW);
shortcutIntent.setDataAndType(path, "application/pdf");
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, pdfName);
Uri requiredUri = Uri.parse("https://developer.android.com/guide/components/intents-common.html").buildUpon()
.appendQueryParameter("utm_source","udacity")
.appendQueryParameter("utm_medium", "course")
.appendQueryParameter("utm_campaign", "android_basics")
.fragment("Phone")
.build();
@sidhuparas
sidhuparas / MyFile.java
Created March 29, 2018 16:26
This is just a cool code.
private void addShortcut(String path1, String pdfName) {
File file = new File(path1);
if (file.exists()) {
Uri path = Uri.fromFile(file);
Intent shortcutIntent = new Intent(Intent.ACTION_VIEW);
shortcutIntent.setDataAndType(path, "application/pdf");
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, pdfName);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".ScrollingActivity">
<android.support.design.widget.AppBarLayout
@sidhuparas
sidhuparas / MainActivity.java
Created July 15, 2018 08:04
movies_arch_comp
import android.app.Activity;
import android.app.Application;
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.View;
public class ItemClickSupport {
private final RecyclerView mRecyclerView;
private OnItemClickListener mOnItemClickListener;
private OnItemLongClickListener mOnItemLongClickListener;
private View.OnClickListener mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/storyModeRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
val layoutManager =
CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL, true)