1) Add This In Manifest.xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Create a new folder name anim in res folder
Animation Files in anim folder
one.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="900"
android:startOffset="500"
android:interpolator="@android:anim/accelerate_interpolator"
>
<translate
android:fromYDelta="200"
android:toYDelta="1"
/>
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
/>
</set>
two.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="800"
android:startOffset="500"
android:interpolator="@android:anim/accelerate_interpolator"
>
<translate
android:fromYDelta="200"
android:toYDelta="0"
/>
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
/>
</set>
three.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="900"
android:startOffset="500"
android:interpolator="@android:anim/accelerate_interpolator"
>
<translate
android:fromXDelta="200"
android:toXDelta="1"
/>
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
/>
</set>
Activity Files
Splash.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:background="#35F9BD"
android:gravity="center"
tools:context=".Splash">
<ImageView
android:id="@+id/spashLogo"
android:layout_width="300dp"
android:layout_height="300dp"
android:src="@drawable/logo"/>
<TextView
android:id="@+id/tvWelcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome"
android:textSize="35sp"
android:textStyle="bold"
android:textColor="@android:color/holo_orange_dark"/>
</LinearLayout>
Splash.java
public class Splash extends AppCompatActivity {
ImageView spashLogo;
TextView tvWelcome;
Animation one, two;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
spashLogo = (ImageView) findViewById(R.id.spashLogo);
tvWelcome = (TextView) findViewById(R.id.tvWelcome);
one = AnimationUtils.loadAnimation(this, R.anim.one);
two = AnimationUtils.loadAnimation(this, R.anim.two);
spashLogo.startAnimation(one);
tvWelcome.startAnimation(two);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent i = new Intent(Splash.this, MainActivity.class);
startActivity(i);
finish();
}
}, 3*1000);
}
}
MainActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:background="#F9FBFF"
android:orientation="vertical"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_width="match_parent"
android:layout_height="230dp"
android:background="@drawable/bgheader"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home"
android:textSize="25sp"
android:textStyle="bold"
android:textColor="@android:color/white"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"/>
</RelativeLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="182dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="@drawable/bgmenus"
android:orientation="vertical"
android:layout_marginTop="-150dp">
<TextView
android:id="@+id/mainmenus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="12dp"
android:text="Main Menus"
android:textColor="#818181"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="4">
<LinearLayout
android:id="@+id/youtube"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical"
android:onClick="Youtube">
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginBottom="8dp"
android:src="@drawable/youtube" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Youtube"
android:textColor="#172646"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/instagram"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical"
android:onClick="Instagram">
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginBottom="8dp"
android:src="@drawable/instagram" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Instagram"
android:textColor="#172646"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linkedin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical"
android:onClick="Linked">
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginBottom="8dp"
android:src="@drawable/linkid" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LinkedIn"
android:textColor="#172646"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/twitter"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical"
android:onClick="Twitter">
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginBottom="8dp"
android:src="@drawable/twitter" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="twitter"
android:textColor="#172646"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/layoutOne">
<LinearLayout
android:layout_width="1.1in"
android:layout_height="182dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="@drawable/bgmenus"
android:gravity="center"
android:orientation="vertical"
android:id="@+id/call"
android:onClick="call">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher_round"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Open Call"
android:textColor="@android:color/black"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:layout_width="1.1in"
android:layout_height="182dp"
android:background="@drawable/bgmenus"
android:gravity="center"
android:orientation="vertical"
android:id="@+id/mail"
android:onClick="mail">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher_round"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Open Gmail"
android:textColor="@android:color/black"
android:textSize="20sp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/layoutTwo">
<LinearLayout
android:layout_width="1.1in"
android:layout_height="182dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="@drawable/bgmenus"
android:gravity="center"
android:orientation="vertical"
android:id="@+id/whatsapp"
android:onClick="whatsapp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher_round"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send Whatsapp"
android:textColor="@android:color/black"
android:textSize="20sp"/>
</LinearLayout>
<LinearLayout
android:layout_width="1.1in"
android:layout_height="182dp"
android:background="@drawable/bgmenus"
android:gravity="center"
android:orientation="vertical"
android:id="@+id/textsms"
android:onClick="textsms">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher_round"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send Text SMS"
android:textColor="@android:color/black"
android:textSize="20sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
MainActivity.java
public class MainActivity extends AppCompatActivity {
LinearLayout youtube, instagram, linkedin, twitter, layoutOne, layoutTwo;
Animation three;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
youtube = (LinearLayout) findViewById(R.id.youtube);
instagram = (LinearLayout) findViewById(R.id.instagram);
linkedin = (LinearLayout) findViewById(R.id.linkedin);
twitter = (LinearLayout) findViewById(R.id.twitter);
layoutOne = (LinearLayout) findViewById(R.id.layoutOne);
layoutTwo = (LinearLayout) findViewById(R.id.layoutTwo);
three = AnimationUtils.loadAnimation(this, R.anim.three);
youtube.startAnimation(three);
instagram.startAnimation(three);
linkedin.startAnimation(three);
twitter.startAnimation(three);
layoutOne.startAnimation(three);
layoutTwo.startAnimation(three);
}
//I Add OnClick Method In XML File
public void Youtube(View V){
String url = "https://www.youtube.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
public void Instagram(View V){
String url = "https://www.instagram.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
public void Linked(View V){
String url = "/https://in.linkedin.com/";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
public void Twitter(View v){
String url = "https://twitter.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
public void call(View view){
int permissionCheck = ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CALL_PHONE);
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.CALL_PHONE}, 1);
} else {
Intent callIntent2 = new Intent(Intent.ACTION_CALL);
callIntent2.setData(Uri.parse("tel:" + "MOBILE_NUMBER"));//change the number
startActivity(callIntent2);
}
}
public void mail(View view){
Intent intent = new Intent (Intent.ACTION_VIEW , Uri.parse("mailto:" + "YOUR_MAIL_ID"));
startActivity(intent);
}
public void whatsapp(View view){
boolean isWhatsappInstalled = whatsappInstalledOrNot("com.whatsapp");
if (isWhatsappInstalled) {
Intent sendIntent = new Intent("android.intent.action.MAIN");
sendIntent.setComponent(new ComponentName("com.whatsapp", "com.whatsapp.Conversation"));
sendIntent.putExtra("jid", PhoneNumberUtils.stripSeparators("8689852249") + "@s.whatsapp.net");//phone number without "+" prefix
startActivity(sendIntent);
} else {
Uri uri = Uri.parse("market://details?id=com.whatsapp");
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
Toast.makeText(MainActivity.this, "WhatsApp not Installed", Toast.LENGTH_SHORT).show();
startActivity(goToMarket);
}
}
private boolean whatsappInstalledOrNot(String uri) {
PackageManager pm = getPackageManager();
boolean app_installed = false;
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
app_installed = true;
} catch (PackageManager.NameNotFoundException e) {
app_installed = false;
}
return app_installed;
}
public void textsms(View view){
Uri uri = Uri.parse("smsto:8689852249");
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
intent.putExtra("sms_body", "The SMS text");
startActivity(intent);
}
}