Skip to content

Instantly share code, notes, and snippets.

View shubhamnikam's full-sized avatar
🎯
focusing

Shubham Nikam shubhamnikam

🎯
focusing
View GitHub Profile
@shubhamnikam
shubhamnikam / MainActivity.java
Created August 12, 2018 16:43
Simple activity lifecycle example using Android log
package com.theappnerds.shubham.activitylifecycle;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.theappnerds.activitylifecycle.R;
public class MainActivity extends AppCompatActivity {
String tag = "ActivityLifecyleStates";
@shubhamnikam
shubhamnikam / activity_main.xml
Created August 13, 2018 14:48
Normal ripple effect
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="?selectableItemBackgroundBorderless">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@shubhamnikam
shubhamnikam / activity_main.xml
Created August 13, 2018 14:55
Strong ripple effect
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/ripple">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="onClick Strong ripple effect"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:orientation="vertical"
tools:context=".MainActivity">
<TextView
@shubhamnikam
shubhamnikam / fab_close.xml
Created August 26, 2018 08:40
Animation for FAB menu
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<scale
android:duration = "300"
android:fromXScale="0.8"
android:fromYScale="0.8"
android:toXScale="0.0"
@shubhamnikam
shubhamnikam / MainActivity.java
Created August 26, 2018 08:51
FAB menu behavior using java
package com.theappnerds.shubham.floatingbutton;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
import android.widget.Toast;
@shubhamnikam
shubhamnikam / MainActivity.java
Created September 3, 2018 12:30
Implicit Intent - Open Link
intentWebsite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Uri uri = Uri.parse("http://www.google.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
@shubhamnikam
shubhamnikam / MainActivity.java
Created September 3, 2018 12:32
Implicit Intent - Email
intentEmail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("text/plain");
intent.setData(Uri.parse("mailto:"));
String[] email = new String[]{"[email protected]"};
String subject = "Email Subject";
String text = "Email text";
@shubhamnikam
shubhamnikam / MainActivity.java
Created September 3, 2018 12:32
Implicit Intent - Share
intentShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
String message = "hey there...";
intent.putExtra(Intent.EXTRA_TEXT, message);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent.createChooser(intent, "Share Using :"));
@shubhamnikam
shubhamnikam / MainActivity.java
Created September 3, 2018 12:33
Implicit Intent - Open Google Play
intentGooglePlay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Uri uri = Uri.parse("market://details?id=" + getApplicationContext().getPackageName());
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}