Downloads :
Important Download , Downloading This Could Make Things More Easy
Watch this video and follow it :
After thinking a lot i decided to start some thing new and help full for by extraordinary visitors . In this tutorial i am going to introduce android studio to you .
About My New Post :
- Build an application for your website
- Setting navigation for your application
- Design your applications with your own icons
- Add share option
- Floating email option
What You Require :
- A computer with android studio installed
- An android phone + Data cable ( For viewing your project , you could also use AVD , GENYMOTION etc )
- On the first place you need a piece of mind and interest in it
In Linux (Ubuntu)
- Download Android Studio , it will be placed at Downloads section .
- Extract the zip file .
- Now lets start with terminal .
- Now lets navigate to Downloads .
- Type cd Downloads and press enter .
- Type ls and press enter .
- Type cd android-studio and press enter .
- Type ls and press enter .
- Type cd bin and press enter.
- Type ls and press enter .
- Type sudo chmod 777 -R ./studio.sh and press enter .
- Type ./studio.sh and press enter .
- Finish up the setup .
- Now android studio is ready to use in your Linux computer .
- Just download Android Studio-32 bit ,
Android Studio-64 bit - Launch the .exe file you downloaded .
- Follow the setup wizard to install Android Studio and any necessary SDK tools .
- Now android studio is ready to use in your Windows computer .
- Start a new Android Studio project .
- Select your application name and package name and in the domain type your website link , click next .
- Select the minimum SDK , click next .
- Select the navigation layout , click next .
- Click finish .
- Now your project builds and after all those Gradle sync and all copy the below codes to the specified folders and be careful don't make any mistakes .
- Now in android open app -> java -> com.appname.app -> MainActivity
- Select the entire codes and replace it with the code below .
- Change all the links of my website to yours and you can do it in the MainActivity.java , All Links Including The WhatsApp , YouTube , Etc . Replace Them With Your Links .
- Now open app -> manifest -> AndroidManifest.xml
- Select the entire codes and replace it with the codes below .
- Now Let's Move To The Layout Part .
- Open -> app -> res -> Layout -> activity_main.xml .
- Select the entire codes and replace it with the codes below .This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout 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" xmlns:fab="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="start"> <include layout="@layout/app_bar_main" android:layout_width="match_parent" android:layout_height="match_parent" /> <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer"> </android.support.design.widget.NavigationView> </android.support.v4.widget.DrawerLayout> - Now open app_bar_main.xml .
- Select the entire codes and replace it with the codes below .
- Now open content_main.xml .
- Select the entire codes and replace it with the codes below .
- Now open nav_header_main.xml .
- Select the entire codes and replace it with the codes below .
- Now Let's Move To The menu Part .
- Open app -> res -> menu -> activity_main_drawer.xml .
- Select the entire codes and replace it with the codes below .
- Now open main.xml .
- Select the entire codes and replace it with the codes below .
- Now you are done with all the Programming part .
- To change the icon of the application go to app -> res -> mipmap . And left click and click view source file and change all the ic_launcher with any of your icon but the name must be same (ic_launcher) .
- Remember All Pictures Should Be In PNG Format .
- Now Build The Apk .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.appname.app; | |
import android.content.Context; | |
import android.content.DialogInterface; | |
import android.content.Intent; | |
import android.graphics.Bitmap; | |
import android.net.ConnectivityManager; | |
import android.net.NetworkInfo; | |
import android.net.Uri; | |
import android.os.AsyncTask; | |
import android.os.Bundle; | |
import android.support.design.widget.FloatingActionButton; | |
import android.support.v7.app.AlertDialog; | |
import android.view.KeyEvent; | |
import android.view.View; | |
import android.support.design.widget.NavigationView; | |
import android.support.v4.view.GravityCompat; | |
import android.support.v4.widget.DrawerLayout; | |
import android.support.v7.app.ActionBarDrawerToggle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.support.v7.widget.Toolbar; | |
import android.view.Menu; | |
import android.view.MenuItem; | |
import android.webkit.WebSettings; | |
import android.webkit.WebView; | |
import android.webkit.WebViewClient; | |
import android.widget.ImageView; | |
import android.widget.ProgressBar; | |
import android.widget.TextView; | |
import android.widget.Toast; | |
import org.json.JSONObject; | |
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.net.URL; | |
public class MainActivity extends AppCompatActivity | |
implements NavigationView.OnNavigationItemSelectedListener { | |
private String ver = "1.0"; | |
private WebView wv; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | |
toolbar.setTitle("TECH MOBS"); | |
setSupportActionBar(toolbar); | |
final ProgressBar progressBar = (ProgressBar) findViewById(R.id.prb); | |
wv = (WebView) this.findViewById(R.id.webview); | |
wv.setWebViewClient(new WebViewClient() { | |
@Override | |
public void onPageStarted(WebView view, String url, Bitmap favicon) { | |
super.onPageStarted(view, url, favicon); | |
progressBar.setVisibility(View.VISIBLE); | |
} | |
@Override | |
public boolean shouldOverrideUrlLoading(WebView webView, String url) | |
{ | |
if(url.contains("tipsandtricksonandroid.blogspot")) { | |
webView.loadUrl(url); | |
} else startActivity(new Intent("android.intent.action.VIEW", Uri.parse(url))); | |
return true; | |
} | |
@Override | |
public void onPageFinished(WebView view, String url) { | |
super.onPageFinished(view, url); | |
progressBar.setVisibility(View.GONE); | |
} | |
}); | |
WebSettings webSettings = wv.getSettings(); | |
webSettings.setJavaScriptEnabled(true); | |
webSettings.getAllowContentAccess(); | |
webSettings.getAllowFileAccess(); | |
webSettings.setDatabaseEnabled(true); | |
webSettings.setAppCacheEnabled(true); | |
if(isInternetAvailable()) { | |
wv.loadUrl("https://tipsandtricksonandroid.blogspot.com/"); | |
} else { | |
progressBar.setVisibility(View.GONE); | |
wv.setVisibility(View.GONE); | |
TextView tv = (TextView) findViewById(R.id.nointv); | |
tv.setVisibility(View.VISIBLE); | |
} | |
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); | |
fab.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
final Intent intent2 = new Intent("android.intent.action.SEND"); | |
intent2.setType("message/rfc822"); | |
intent2.putExtra("android.intent.extra.EMAIL", new String[]{"techmobs.in@gmail.com"}); | |
intent2.putExtra("android.intent.extra.SUBJECT", "TECH MOBS v" + ver); | |
intent2.putExtra("android.intent.extra.TEXT", ""); | |
try { | |
startActivity(Intent.createChooser(intent2, "Report...")); | |
} catch (Exception ex) { | |
Toast.makeText(MainActivity.this, "Can't find email client.", Toast.LENGTH_SHORT).show(); | |
} | |
} | |
}); | |
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); | |
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( | |
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); | |
drawer.setDrawerListener(toggle); | |
toggle.syncState(); | |
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); | |
navigationView.setNavigationItemSelectedListener(this); | |
setupNavigationHeader(navigationView); | |
} | |
@Override | |
public void onBackPressed() { | |
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); | |
if (drawer.isDrawerOpen(GravityCompat.START)) { | |
drawer.closeDrawer(GravityCompat.START); | |
} else { | |
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this); | |
alertDialogBuilder.setTitle("Exit"); | |
alertDialogBuilder | |
.setMessage("Do you really want to exit?") | |
.setCancelable(false) | |
.setPositiveButton("Yes",new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog,int id) { | |
MainActivity.this.finish(); | |
} | |
}) | |
.setNegativeButton("No",new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog,int id) { | |
dialog.cancel(); | |
} | |
}).show(); | |
} | |
} | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
getMenuInflater().inflate(R.menu.main, menu); | |
return true; | |
} | |
@Override | |
public boolean onOptionsItemSelected(MenuItem item) { | |
int id = item.getItemId(); | |
if (id == R.id.action_web) { | |
startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://tipsandtricksonandroid.blogspot.in"))); | |
} else if (id == R.id.action_fb) { | |
startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://www.facebook.com/tipsandtricksonandroid/"))); | |
} else if (id == R.id.action_gplus) { | |
startActivity(new Intent("android.intent.action.VIEW", Uri.parse("https://plus.google.com/+VISHNUS%20TRICKS"))); | |
} | |
return super.onOptionsItemSelected(item); | |
} | |
@SuppressWarnings("StatementWithEmptyBody") | |
@Override | |
public boolean onNavigationItemSelected(MenuItem item) { | |
int id = item.getItemId(); | |
if (id == R.id.nav_youtube) { | |
wv.loadUrl("https://www.youtube.com/c/vishnusivadas"); | |
} else if (id == R.id.nav_exit) { | |
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); | |
alertDialogBuilder.setTitle((CharSequence) "Exit"); | |
alertDialogBuilder.setMessage((CharSequence) "Do you really want to exit?") .setCancelable(false) | |
.setPositiveButton("Yes",new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog,int id) { | |
MainActivity.this.finish(); | |
} | |
}) | |
.setNegativeButton("No",new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog,int id) { | |
dialog.cancel(); | |
} | |
}).show(); | |
} | |
else if (id == R.id.nav_home) { | |
this.wv.loadUrl("https://tipsandtricksonandroid.blogspot.in/"); | |
}else if (id == R.id.nav_blog) { | |
this.wv.loadUrl("https://tipsandtricksonandroid.blogspot.in/search?max-result=10"); | |
}else if (id == R.id.nav_about) { | |
this.wv.loadUrl("http://tipsandtricksonandroid.blogspot.in/p/about.html"); | |
} else if (id == R.id.nav_contact) { | |
this.wv.loadUrl("http://tipsandtricksonandroid.blogspot.in/p/contact.html"); | |
} | |
else if (id == R.id.nav_whatsapp) { | |
wv.loadUrl("https://chat.whatsapp.com/6NuAILVAIVjEjP6MaC0rCR"); | |
} | |
else if (id == R.id.nav_share) { | |
final String string = "TECH MOBS - Official Application v"+ ver + " :\n" + | |
"\n" + | |
" 1. Hacked Games\n" + | |
" 2. Hacked Apps\n" + | |
" 3. Hacking Tricks\n" + | |
" 4. Tutorials On Programming \n" + | |
" 5. Social Media Tricks\n" + | |
" 6. Wi-Fi Hacking Tutorial\n" + | |
" 7. Contact Us Faster\n" + | |
" 8. Email Me \n" + | |
" 9. Find Me On Facebook\n" + | |
"10. Easy Donate Option \n" + | |
"11. Best Browsing Experience \n" + | |
"12. No Advertisements\n "+ | |
"13. Automatic Update Notifier\n" + | |
"Download Our Application At : https://tipsandtricksonandroid.blogspot.in/p/techmob-application.html\n"+ | |
"\n"+ | |
"Share It To All And Enjoy ....:)"; | |
final Intent intent3 = new Intent("android.intent.action.SEND"); | |
intent3.setType("text/plain"); | |
intent3.putExtra("android.intent.extra.SUBJECT", "TECH MOBS"); | |
intent3.putExtra("android.intent.extra.TEXT", string); | |
startActivity(Intent.createChooser(intent3, "Share")); | |
} | |
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); | |
drawer.closeDrawer(GravityCompat.START); | |
return true; | |
} | |
@Override | |
public boolean onKeyDown(int keyCode, KeyEvent event) | |
{ | |
if((keyCode == KeyEvent.KEYCODE_BACK)&& wv.canGoBack()) | |
{ | |
wv.goBack(); | |
return true; | |
} | |
return super.onKeyDown(keyCode, event); | |
} | |
//other | |
private boolean isInternetAvailable() { | |
ConnectivityManager connectivityManager | |
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); | |
return activeNetworkInfo != null && activeNetworkInfo.isConnected(); | |
} | |
public void setupNavigationHeader(NavigationView mNavigationView) { | |
View headerView = mNavigationView.getHeaderView(0); | |
TextView navAppVersion = (TextView) headerView.findViewById(R.id.tv); | |
try { | |
navAppVersion.setText("Developer : Vishnu Sivadas"); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.appname.app"> | |
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |
<uses-permission android:name="android.permission.READ_LOGS" /> | |
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" /> | |
<uses-permission android:name="android.permission.INTERNET" /> | |
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | |
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | |
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | |
<application | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" | |
android:supportsRtl="true" | |
android:theme="@style/AppTheme"> | |
<activity | |
android:name=".MainActivity" | |
android:label="@string/app_name" | |
android:theme="@style/AppTheme.NoActionBar"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> | |
</application> | |
</manifest> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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="com.appname.app.MainActivity"> | |
<android.support.design.widget.AppBarLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:theme="@style/AppTheme.AppBarOverlay"> | |
<android.support.v7.widget.Toolbar | |
android:id="@+id/toolbar" | |
android:layout_width="match_parent" | |
android:layout_height="?attr/actionBarSize" | |
android:background="?attr/colorPrimary" | |
app:popupTheme="@style/AppTheme.PopupOverlay" /> | |
</android.support.design.widget.AppBarLayout> | |
<include | |
android:id="@+id/tv" | |
layout="@layout/content_main" /> | |
<android.support.design.widget.FloatingActionButton | |
android:id="@+id/fab" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_gravity="bottom|end" | |
android:layout_margin="@dimen/fab_margin" | |
app:srcCompat="@android:drawable/ic_dialog_email" /> | |
</android.support.design.widget.CoordinatorLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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:id="@+id/content_main" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:layout_behavior="@string/appbar_scrolling_view_behavior" | |
tools:context="com.appname.app.MainActivity" | |
tools:showIn="@layout/app_bar_main"> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:paddingBottom="@dimen/activity_vertical_margin" | |
android:paddingLeft="@dimen/activity_horizontal_margin" | |
android:paddingRight="@dimen/activity_horizontal_margin" | |
android:paddingTop="@dimen/activity_vertical_margin" | |
android:gravity="center" | |
android:textStyle="bold" | |
android:textSize="25sp" | |
android:text="You Are Not Connected To Internet : Connect To Internet And Try Again" | |
android:id="@+id/nointv" | |
android:visibility="gone"/> | |
<WebView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:id="@+id/webview" | |
android:layout_alignParentBottom="true" | |
android:layout_alignParentLeft="true" | |
android:layout_alignParentStart="true" /> | |
<ProgressBar | |
style="?android:attr/progressBarStyleLarge" | |
android:layout_centerHorizontal="true" | |
android:layout_height="match_parent" | |
android:layout_width="wrap_content" | |
android:layout_gravity="center_vertical|center_horizontal" | |
android:layout_alignTop="@+id/nointv" | |
android:id="@+id/prb"/> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<menu xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:android="http://schemas.android.com/apk/res/android"> | |
<group android:checkableBehavior="single"> | |
<item | |
android:id="@+id/nav_home" | |
android:title="Home" | |
android:icon="@drawable/home" /> | |
<item | |
android:title="Blog" | |
android:icon="@drawable/blog" | |
android:id="@+id/nav_blog" /> | |
<item | |
android:id="@+id/nav_about" | |
android:title="About" | |
android:icon="@android:drawable/ic_dialog_info" /> | |
<item | |
android:id="@+id/nav_contact" | |
android:title="Contact" | |
android:icon="@drawable/contact" /> | |
<item | |
android:id="@+id/nav_youtube" | |
android:icon="@drawable/yt" | |
android:title="Youtube" /> | |
<item | |
android:id="@+id/nav_whatsapp" | |
android:icon="@drawable/wa" | |
android:title="Whatsapp" /> | |
<item | |
android:id="@+id/nav_share" | |
android:icon="@drawable/share" | |
android:title="Share" /> | |
<item | |
android:id="@+id/nav_exit" | |
android:icon="@drawable/close" | |
android:title="Exit" /> | |
</group> | |
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<menu xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto"> | |
<group android:checkableBehavior="single"/> | |
<item | |
android:id="@+id/action_web" | |
android:orderInCategory="102" | |
android:title="website" | |
android:icon="@drawable/web" | |
app:showAsAction="always" /> | |
<item | |
android:id="@+id/action_fb" | |
android:orderInCategory="102" | |
android:title="facebook" | |
android:icon="@drawable/fb" | |
app:showAsAction="always" /> | |
<item | |
android:id="@+id/action_gplus" | |
android:orderInCategory="102" | |
android:title="gplus" | |
android:icon="@drawable/gplus" | |
app:showAsAction="always" /> | |
</menu> |
IMPORTANT NOTES :
- Rename com.appname.app (package name) to that you have used .
- Place The Necessary Drawable Files In The Drawable Of Your Applications File
Downloads :
Important Download , Downloading This Could Make Things More Easy
Part 3 - Set Up An In-Build Update Checker For Your Application ( Link To The Post - Click Here )
super and its really good . i was looking for something like this . please continue with your android studio projects........
ReplyDeleteThanks A Lot For Your Words . And I am happy to know that you got what you where looking for . Enjoy ....
DeleteWow........ Can you publish splash screen tutorial faster .... please .....
ReplyDeleteSure I Would Make It As Fast As Possible
Delete