View source code any website very simple example application devlopered by edu porpers   Example video :- Download App                      ...

View source code any website very simple example application devlopered by edu porpers

  Example video :-






Download App                                                                                              Download code


Let go start 



Creating the User Interface

To start, we are going to create the user interface of our Torch view sroce Application  the Android device..


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="#a3c539">
        <EditText
            android:id="@+id/et1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="Enter your url"
            android:textSize="14sp"
            android:padding="8dp"
            android:textColor="#fff"
            android:textStyle="bold"
            android:textColorHint="#fff"
            android:layout_weight="1"
            android:background="@android:color/transparent"/>
        <ImageView
            android:onClick="done"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:src="@drawable/ic_arrow_forward_black_24dp"
            android:scaleType="fitCenter"/>
    </LinearLayout>
    <WebView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/webview">
    </WebView>
</LinearLayout>



Updating the Android Manifest

<uses-permission android:name="android.permission.INTERNET"/>


MainActivity.java

package neo.com.viewsourcecode;

import android.graphics.Bitmap;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    private WebView webview;
    private EditText et1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        webview = findViewById(R.id.webview);
        et1 = findViewById(R.id.et1);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.getSettings().setDisplayZoomControls(true);
        webview.getSettings().setSupportZoom(true);
        webview.setWebViewClient( new WebViewClient(){
            @Override
            public void onPageStarted(WebView param1, String param2, Bitmap param3){
                final String Url= param2;

            }
            @Override
            public void onPageFinished(WebView param1, String param2){
                final String Url= param2;

            }
        });

    }

    public void done(View view) {
      if(et1.getText().toString().equals("https://") && et1.getText().toString().equals("https://")){
          webview.loadUrl("view-source"+et1.getText().toString());
      } else {
          webview.loadUrl("view-source:https://"+et1.getText().toString());
      }
    }
}

                            Devloped by manikantasripadi

IN SKETHWARE

I cant explain sorry see this video skectchware usere


video:







Devloped by manikantasripadi


given below Sr.NoMethod & Description1 execSQL(String sql, Object[] bindArgs) This method not only insert data , but also used to update...

given below

Sr.NoMethod & Description1

execSQL(String sql, Object[] bindArgs)

This method not only insert data , but also used to update or modify already existing data in database using bind arguments

Database - Fetching


We can retrieve anything from database using an object of the Cursor class. We will call a method of this class called rawQuery and it will return a resultset with the cursor pointing to the table. We can move the cursor forward and retrieve the data.

Cursor resultSet = mydatbase.rawQuery("Select * from TutorialsPoint",null); resultSet.moveToFirst(); String username = resultSet.getString(0); String password = resultSet.getString(1);

There are other functions available in the Cursor class that allows us to effectively retrieve the data. That includes

Sr.NoMethod & Description1

getColumnCount()

This method return the total number of columns of the table.

2

getColumnIndex(String columnName)

This method returns the index number of a column by specifying the name of the column

3

getColumnName(int columnIndex)

This method returns the name of the column by specifying the index of the column

4

getColumnNames()

This method returns the array of all the column names of the table.

5

getCount()

This method returns the total number of rows in the cursor

6

getPosition()

This method returns the current position of the cursor in the table

7

isClosed()

This method returns true if the cursor is closed and return false otherwise

Database - Helper class


For managing all the operations related to the database , an helper class has been given and is called SQLiteOpenHelper. It automatically manages the creation and update of the database. Its syntax is given below

public class DBHelper extends SQLiteOpenHelper { public DBHelper(){ super(context,DATABASE_NAME,null,1); } public void onCreate(SQLiteDatabase db) {} public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {} }

Example


Here is an example demonstrating the use of SQLite Database. It creates a basic contacts applications that allows insertion, deletion and modification of contacts.

To experiment with this example, you need to run this on an actual device on which camera is supported.

StepsDescription1You will use Android studio to create an Android application under a package com.example.sairamkrishna.myapplication.2Modify src/MainActivity.java file to get references of all the XML components and populate the contacts on listView.3Create new src/DBHelper.java that will manage the database work4Create a new Activity as DisplayContact.java that will display the contact on the screen5Modify the res/layout/activity_main to add respective XML components6Modify the res/layout/activity_display_contact.xml to add respective XML components7Modify the res/values/string.xml to add necessary string components8Modify the res/menu/display_contact.xml to add necessary menu components9Create a new menu as res/menu/mainmenu.xml to add the insert contact option10Run the application and choose a running android device and install the application on it and verify the results.

Following is the content of the modified MainActivity.java.

package com.example.sairamkrishna.myapplication; import android.content.Context; import android.content.Intent; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import java.util.ArrayList; import java.util.List; public class MainActivity extends ActionBarActivity { public final static String EXTRA_MESSAGE = "MESSAGE"; private ListView obj; DBHelper mydb; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mydb = new DBHelper(this); ArrayList array_list = mydb.getAllCotacts(); ArrayAdapter arrayAdapter=new ArrayAdapter(this,android.R.layout.simple_list_item_1, array_list); obj = (ListView)findViewById(R.id.listView1); obj.setAdapter(arrayAdapter); obj.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) { // TODO Auto-generated method stub int id_To_Search = arg2 + 1; Bundle dataBundle = new Bundle(); dataBundle.putInt("id", id_To_Search); Intent intent = new Intent(getApplicationContext(),DisplayContact.class); intent.putExtras(dataBundle); startActivity(intent); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item){ super.onOptionsItemSelected(item); switch(item.getItemId()) { case R.id.item1:Bundle dataBundle = new Bundle(); dataBundle.putInt("id", 0); Intent intent = new Intent(getApplicationContext(),DisplayContact.class); intent.putExtras(dataBundle); startActivity(intent); return true; default: return super.onOptionsItemSelected(item); } } public boolean onKeyDown(int keycode, KeyEvent event) { if (keycode == KeyEvent.KEYCODE_BACK) { moveTaskToBack(true); } return super.onKeyDown(keycode, event); } }

Following is the modified content of display contact activity DisplayContact.java

package com.example.sairamkrishna.myapplication; import android.os.Bundle; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.database.Cursor; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; public class DisplayContact extends Activity { int from_Where_I_Am_Coming = 0; private DBHelper mydb ; TextView name ; TextView phone; TextView email; TextView street; TextView place; int id_To_Update = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_contact); name = (TextView) findViewById(R.id.editTextName); phone = (TextView) findViewById(R.id.editTextPhone); email = (TextView) findViewById(R.id.editTextStreet); street = (TextView) findViewById(R.id.editTextEmail); place = (TextView) findViewById(R.id.editTextCity); mydb = new DBHelper(this); Bundle extras = getIntent().getExtras(); if(extras !=null) { int Value = extras.getInt("id"); if(Value>0){ //means this is the view part not the add contact part. Cursor rs = mydb.getData(Value); id_To_Update = Value; rs.moveToFirst(); String nam = rs.getString(rs.getColumnIndex(DBHelper.CONTACTS_COLUMN_NAME)); String phon = rs.getString(rs.getColumnIndex(DBHelper.CONTACTS_COLUMN_PHONE)); String emai = rs.getString(rs.getColumnIndex(DBHelper.CONTACTS_COLUMN_EMAIL)); String stree = rs.getString(rs.getColumnIndex(DBHelper.CONTACTS_COLUMN_STREET)); String plac = rs.getString(rs.getColumnIndex(DBHelper.CONTACTS_COLUMN_CITY)); if (!rs.isClosed()) { rs.close(); } Button b = (Button)findViewById(R.id.button1); b.setVisibility(View.INVISIBLE); name.setText((CharSequence)nam); name.setFocusable(false); name.setClickable(false); phone.setText((CharSequence)phon); phone.setFocusable(false); phone.setClickable(false); email.setText((CharSequence)emai); email.setFocusable(false); email.setClickable(false); street.setText((CharSequence)stree); street.setFocusable(false); street.setClickable(false); place.setText((CharSequence)plac); place.setFocusable(false); place.setClickable(false); } } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. Bundle extras = getIntent().getExtras(); if(extras !=null) { int Value = extras.getInt("id"); if(Value>0){ getMenuInflater().inflate(R.menu.display_contact, menu); } else{ getMenuInflater().inflate(R.menu.menu_main menu); } } return true; } public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); switch(item.getItemId()) { case R.id.Edit_Contact: Button b = (Button)findViewById(R.id.button1); b.setVisibility(View.VISIBLE); name.setEnabled(true); name.setFocusableInTouchMode(true); name.setClickable(true); phone.setEnabled(true); phone.setFocusableInTouchMode(true); phone.setClickable(true); email.setEnabled(true); email.setFocusableInTouchMode(true); email.setClickable(true); street.setEnabled(true); street.setFocusableInTouchMode(true); street.setClickable(true); place.setEnabled(true); place.setFocusableInTouchMode(true); place.setClickable(true); return true; case R.id.Delete_Contact: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.deleteContact) .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { mydb.deleteContact(id_To_Update); Toast.makeText(getApplicationContext(), "Deleted Successfully", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(getApplicationContext(),MainActivity.class); startActivity(intent); } }) .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); AlertDialog d = builder.create(); d.setTitle("Are you sure"); d.show(); return true; default: return super.onOptionsItemSelected(item); } } public void run(View view) { Bundle extras = getIntent().getExtras(); if(extras !=null) { int Value = extras.getInt("id"); if(Value>0){ if(mydb.updateContact(id_To_Update,name.getText().toString(), phone.getText().toString(), email.getText().toString(), street.getText().toString(), place.getText().toString())){ Toast.makeText(getApplicationContext(), "Updated", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(getApplicationContext(),MainActivity.class); startActivity(intent); } else{ Toast.makeText(getApplicationContext(), "not Updated", Toast.LENGTH_SHORT).show(); } } else{ if(mydb.insertContact(name.getText().toString(), phone.getText().toString(), email.getText().toString(), street.getText().toString(), place.getText().toString())){ Toast.makeText(getApplicationContext(), "done", Toast.LENGTH_SHORT).show(); } else{ Toast.makeText(getApplicationContext(), "not done", Toast.LENGTH_SHORT).show(); } Intent intent = new Intent(getApplicationContext(),MainActivity.class); startActivity(intent); } } } }

Following is the content of Database class DBHelper.java

package com.example.sairamkrishna.myapplication; import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.DatabaseUtils; import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteDatabase; public class DBHelper extends SQLiteOpenHelper { public static final String DATABASE_NAME = "MyDBName.db"; public static final String CONTACTS_TABLE_NAME = "contacts"; public static final String CONTACTS_COLUMN_ID = "id"; public static final String CONTACTS_COLUMN_NAME = "name"; public static final String CONTACTS_COLUMN_EMAIL = "email"; public static final String CONTACTS_COLUMN_STREET = "street"; public static final String CONTACTS_COLUMN_CITY = "place"; public static final String CONTACTS_COLUMN_PHONE = "phone"; private HashMap hp; public DBHelper(Context context) { super(context, DATABASE_NAME , null, 1); } @Override public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub db.execSQL( "create table contacts " + "(id integer primary key, name text,phone text,email text, street text,place text)" ); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub db.execSQL("DROP TABLE IF EXISTS contacts"); onCreate(db); } public boolean insertContact (String name, String phone, String email, String street,String place) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues contentValues = new ContentValues(); contentValues.put("name", name); contentValues.put("phone", phone); contentValues.put("email", email); contentValues.put("street", street); contentValues.put("place", place); db.insert("contacts", null, contentValues); return true; } public Cursor getData(int id) { SQLiteDatabase db = this.getReadableDatabase(); Cursor res = db.rawQuery( "select * from contacts where id="+id+"", null ); return res; } public int numberOfRows(){ SQLiteDatabase db = this.getReadableDatabase(); int numRows = (int) DatabaseUtils.queryNumEntries(db, CONTACTS_TABLE_NAME); return numRows; } public boolean updateContact (Integer id, String name, String phone, String email, String street,String place) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues contentValues = new ContentValues(); contentValues.put("name", name); contentValues.put("phone", phone); contentValues.put("email", email); contentValues.put("street", street); contentValues.put("place", place); db.update("contacts", contentValues, "id = ? ", new String[] { Integer.toString(id) } ); return true; } public Integer deleteContact (Integer id) { SQLiteDatabase db = this.getWritableDatabase(); return db.delete("contacts", "id = ? ", new String[] { Integer.toString(id) }); } public ArrayList<String> getAllCotacts() { ArrayList<String> array_list = new ArrayList<String>(); //hp = new HashMap(); SQLiteDatabase db = this.getReadableDatabase(); Cursor res = db.rawQuery( "select * from contacts", null ); res.moveToFirst(); while(res.isAfterLast() == false){ array_list.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_NAME))); res.moveToNext(); } return array_list; } }

Following is the content of the res/layout/activity_main.xml

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textView" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:textSize="30dp" android:text="Data Base" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Tutorials Point" android:id="@+id/textView2" android:layout_below="@+id/textView" android:layout_centerHorizontal="true" android:textSize="35dp" android:textColor="#ff16ff01" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageView" android:layout_below="@+id/textView2" android:layout_centerHorizontal="true" android:src="@drawable/logo"/> <ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/scrollView" android:layout_below="@+id/imageView" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true"> <ListView android:id="@+id/listView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" > </ListView> </ScrollView> </RelativeLayout>

Following is the content of the res/layout/activity_display_contact.xml

<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/scrollView1" android:layout_width="match_parent" android:layout_height="wrap_content" tools:context=".DisplayContact" > <RelativeLayout android:layout_width="match_parent" android:layout_height="370dp" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin"> <EditText android:id="@+id/editTextName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_marginTop="5dp" android:layout_marginLeft="82dp" android:ems="10" android:inputType="text" > </EditText> <EditText android:id="@+id/editTextEmail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/editTextStreet" android:layout_below="@+id/editTextStreet" android:layout_marginTop="22dp" android:ems="10" android:inputType="textEmailAddress" /> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/editTextName" android:layout_alignParentLeft="true" android:text="@string/name" android:textAppearance="?android:attr/textAppearanceMedium" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/editTextCity" android:layout_alignParentBottom="true" android:layout_marginBottom="28dp" android:onClick="run" android:text="@string/save" /> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/editTextEmail" android:layout_alignLeft="@+id/textView1" android:text="@string/email" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:id="@+id/textView5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/editTextPhone" android:layout_alignLeft="@+id/textView1" android:text="@string/phone" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/editTextEmail" android:layout_alignLeft="@+id/textView5" android:text="@string/street" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:id="@+id/editTextCity" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignRight="@+id/editTextName" android:layout_below="@+id/editTextEmail" android:layout_marginTop="30dp" android:ems="10" android:inputType="text" /> <TextView android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/editTextCity" android:layout_alignBottom="@+id/editTextCity" android:layout_alignParentLeft="true" android:layout_toLeftOf="@+id/editTextEmail" android:text="@string/country" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:id="@+id/editTextStreet" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/editTextName" android:layout_below="@+id/editTextPhone" android:ems="10" android:inputType="text" > <requestFocus /> </EditText> <EditText android:id="@+id/editTextPhone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/editTextStreet" android:layout_below="@+id/editTextName" android:ems="10" android:inputType="phone|text" /> </RelativeLayout> </ScrollView>

Following is the content of the res/value/string.xml

<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Address Book</string> <string name="action_settings">Settings</string> <string name="hello_world">Hello world!</string> <string name="Add_New">Add New</string> <string name="edit">Edit Contact</string> <string name="delete">Delete Contact</string> <string name="title_activity_display_contact">DisplayContact</string> <string name="name">Name</string> <string name="phone">Phone</string> <string name="email">Email</string> <string name="street">Street</string> <string name="country">City/State/Zip</string> <string name="save">Save Contact</string> <string name="deleteContact">Are you sure, you want to delete it.</string> <string name="yes">Yes</string> <string name="no">No</string> </resources>

Following is the content of the res/menu/main_menu.xml

<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/item1" android:icon="@drawable/add" android:title="@string/Add_New" > </item> </menu>

Following is the content of the res/menu/display_contact.xml

<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/Edit_Contact" android:orderInCategory="100" android:title="@string/edit"/> <item android:id="@+id/Delete_Contact" android:orderInCategory="100" android:title="@string/delete"/> </menu>

This is the defualt AndroidManifest.xml of this project

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.sairamkrishna.myapplication" > <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".DisplayContact"/> </application> </manifest>

Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from Android studio , open one of your project's activity files and click Run  icon from the tool bar. Before starting your application,Android studio will display following window to select an option where you want to run your Android application.

Select your mobile device as an option and then check your mobile device which will display following screen −

Now open your optional menu, it will show as below image: Optional menu appears different places on different versions

Click on the add button of the menu screen to add a new contact. It will display the following screen −

It will display the following fields. Please enter the required information and click on save contact. It will bring you back to main screen.

Now our contact sai has been added.In order to see that where is your database is created. Open your android studio, connect your mobile. Go tools/android/android device monitor. Now browse the file explorer tab. Now browse this folder /data/data/<your.package.name>/databases<database-name>.

Imageview image setus wallpapers   prview: Lets make up: setp 1: creating projects in android studio or sketchware  step2: open activity_mai...

Imageview image setus wallpapers

  prview:

Lets make up:

setp 1:

creating projects in android studio or sketchware 

step2:
open activity_main.xml

Main_xml:


   

MainActivty:



package nwallpapers.com.neo.istone.andro.project.wallpapers.nwallpapers;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.app.WallpaperManager;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.media.Image;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;

public class MaiActivity extends Activity {

    private Bitmap bitmap;
    private Timer timer = new Timer();
    private TimerTask _timer;
    private ImageView images;
    private Button set_us;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main );
         images = (ImageView) findViewById(R.id.iview);
         set_us = (Button) findViewById(R.id.set); 
         set_us.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setWallpapers();
            }
        });
    }
    private void setWallpapers() {
        bitmap = ((BitmapDrawable)images.getDrawable()).getBitmap();
        final WallpaperManager myWallManager = WallpaperManager.getInstance( getApplicationContext() );
        try {
            final ProgressDialog progressDialog = new ProgressDialog(emple.this);
            progressDialog.setMax(100);
            progressDialog.setMessage("Loading...");
            progressDialog.setIndeterminate(true);
            progressDialog.setCanceledOnTouchOutside(false);
            progressDialog.show();
            _timer = new TimerTask() {
                @Override
                public void run() {
                    runOnUiThread( new Runnable() {
                        @Override
                        public void run() {
                            try {
                                myWallManager.setBitmap(bitmap );
                                progressDialog.dismiss();
                                final AlertDialog.Builder setus = new AlertDialog.Builder(emple.this);
                                setus.setMessage(R.string.set_wallpapers_secufully);
                                setus.show();
                                progressDialog.dismiss();
                            } catch (IOException e) {
                                final AlertDialog.Builder setus = new AlertDialog.Builder(emple.this);
                                setus.setTitle(R.string.set_wallpapers_error);
                                setus.setMessage(e.toString());
                                setus.show();
                                progressDialog.dismiss();

                            }
                        }
                    } );
                }
            };
            timer.schedule( _timer, (3500) );

        } catch (Exception e) {
            final AlertDialog.Builder setus = new AlertDialog.Builder(emple.this);
            setus.setTitle(R.string.set_wallpapers_error);
            setus.setMessage(R.string.set_wallpapers_error);
            setus.show();
        }
    }
}

Make Follow This Steps: Open Android Studio  :- Step2:-  Step3:- Step4:- Step5: activty_main.xml Code in pasting main.xml At w3schools.com y...

Make Follow This Steps:



Open Android Studio  :-




Step2:- 


Step3:-

Step4:-






Step5:

activty_main.xml

Code in pasting main.xml

Step6:

costum.xml

Code in pasting costum.xml

Step7:

MainActivity.java

Code in pasting MainActivity.java
package com.neo_istone.muiltipleedittext; import android.content.DialogInterface; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; import org.w3c.dom.Text; public class MainActivity extends AppCompatActivity { private Button btn1; private TextView name,email,age; private AlertDialog.Builder builder; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btn1 = (Button) findViewById(R.id.showme_dialog_box); builder = new AlertDialog.Builder(this); name = (TextView) findViewById(R.id.name); email = (TextView) findViewById(R.id.email); age = (TextView) findViewById(R.id.age); btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { builder.setTitle("MulitipleEditTexts"); final View v2 = (View)getLayoutInflater().inflate(R.layout.coustom_dialog_box,null); builder.setView(v2); final TextView name2 =(TextView) v2.findViewById(R.id.name2); final TextView email2 =(TextView) v2.findViewById(R.id.email2); final TextView ag2 =(TextView) v2.findViewById(R.id.age2); builder.setPositiveButton("Shome Text", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if(name2.getText().toString().equals("")){ name.setText("N/A"); }else { if (email2.getText().toString().equals("")){ email.setText("N/A"); } else { if (ag2.getText().toString().equals("")){ email.setText("N/A"); } else { name.setText(name2.getText().toString()); email.setText(email2.getText().toString()); age.setText(ag2.getText().toString()); } } } } }); builder.show(); } }); } }

App Screenshots:

                                            screnenShot:1

                                                          screnenShot:2

Hi. Here i want show you how to use Android GPS quickly. This is simple, may be not perfect example how to get current location by GPS. To u...

Hi. Here i want show you how to use Android GPS quickly. This is simple, may be not perfect example how to get current location by GPS.

To use GPS in your application first of all you must specify the uses-permission in Android manifest file:



If you don’t set this permission the application can’t get access to location service.
To use this application with android emulator you must mock location data. To do this using Eclipse you must:
  • Select Window > Show View > Other > Emulator Control
  • In Emulator Control panel enter the GPS coordinates under Location Controls and press Send
This operation you must do every time then you Run application.
Below you can see the application activity (HelloAndroidGpsActivity.java) source. Below you can download the source code of this Android project.
For more information about Android GPS Usage look HERE

MainActivity.java 

Full code:


In that tutorial, you are going to learn how to create a Torch Flashlight application for Android with Android Studio. A lot of tutorials ex...

In that tutorial, you are going to learn how to create a Torch Flashlight application for Android with Android Studio. A lot of tutorials exist to teach you to use the flashlight of your device via the Camera API but this API is now deprecated since Android API level 25.
So, to be up to date we are going to use the Camera2 API in this tutorial. Note that you can discover this tutorial in video on YouTube :

Creating the User Interface

To start, we are going to create the user interface of our Torch Flashlight Application for Android. We will have one image view to display an ON / OFF switcher image. Then, a button to enable the camera permissions to use the flashlight on the Android device..

Activity_Main.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/background">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/app_names"
        android:textColor="@color/Whit"
        android:textSize="28sp"
        android:gravity="center_horizontal|center_vertical"
        android:textStyle="bold" />

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center_horizontal|center_vertical">
      <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"
          android:layout_weight="1">

      </LinearLayout>
    <ImageButton
        android:id="@+id/Switch"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/background"
        android:src="@drawable/off" />
  <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:layout_weight="1"
      android:gravity="bottom|right">
      <TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="This app devloped by neo-istone"
          android:textStyle="bold"
          android:textSize="14sp"
          android:textColor="#fff"/>
  </LinearLayout>
</LinearLayout>
</LinearLayout>



Updating the Android Manifest

Then, we are going to add the CAMERA permission in the android manifest and we also define the fact that we use the camera in our application :

Updating the Gradle Build File

To use the Camera2 API with no warnings on Android Studio, we are going to set the minimum Android SDK version to 23 in the Gradle Build File :

Writing the Java Code

Now, it’s time to write the Java code of the Main Activity. First, we declare a constant for the CAMERA_REQUEST request index used to request camera permissions. Then, we declare properties for the enable button and for the image view. We define a flashlight status Boolean which will indicate us if the flashlight is on or off.
In the onCreate method, we get references for the ImageView and for the button. We check if the device has a camera. We check also if the camera permission has already been granted by the user for the application. We manage the state of the button and the imageview according the camera permission authorization. We install an OnClickListener on the enable button. When the user will click on this button we will request permission for the Camera permission with the Camera Request id in parameter.

We set an OnClickListener on the ImageView. When a user will click on the image view, first we check if the device has camera flash. If no, we display a message to alert the user. Otherwise, we turn off the light if needed by calling the flashLightOff method. And we turn on the light if needed by calling the flashLightOn method.


 <?xml version="1.0" encoding="utf-8"?>
Switch.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View view) {
    if (hasCameraFlash) {
      if (flashLightStatus)
        flashLightOff();
      else
        flashLightOn();
    } else {
      Toast.makeText(MainActivity.this, "No flash available on your device",
            Toast.LENGTH_SHORT).show();
    }
  }
});

Now, we write the flashLightOn method. We get the camera service. Usually, the front camera is at the first position. With the camera manager we call the set torch mode method with cameraId in parameter to enable it. We set the flashlight status to true and we change the image in the image view.


@TargetApi(Build.VERSION_CODES.M)
    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    private void flashLightOn() {
        CameraManager cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);

        try {
            String cameraId = cameraManager.getCameraIdList()[0];
            cameraManager.setTorchMode(cameraId, true);
            flashLightStatus = true;
            Switch.setImageResource(R.drawable.on);
        } catch (CameraAccessException e) {
            Toast.makeText(this,e.toString(),Toast.LENGTH_SHORT).show();
        }
    }

Now, we write the flashLightOff method. We get the camera service. Usually, the front camera is at the first position. With the camera manager we call the set torch mode method with cameraId in parameter to enable it. We set the flashlight status to true and we change the image in the image view.

@RequiresApi(api = Build.VERSION_CODES.M)
    private void flashLightOff() {
        CameraManager cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);

        try {
            String cameraId = cameraManager.getCameraIdList()[0];
            cameraManager.setTorchMode(cameraId, false);
            flashLightStatus = false;
            Switch.setImageResource(R.drawable.off);
        } catch (CameraAccessException e) {
            Toast.makeText(this,e.toString(),Toast.LENGTH_SHORT).show();
        }
    }
Finally, we override the onRequestPermissionsResult method. We check if the user has granted the camera permission. If yes, we disable the enable button and we change the text of the button to display a camera enabled message. Then, we enable the ImageView to let the user light up the Flashlight of their device :


MainActivity.java 

Full code:

package light.flash.istone.neo.com.flashlightapp;

import android.Manifest;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Camera;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraManager;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    ImageButton Switch;
    private static final int CAMERA_REQUEST = 50;
    private boolean flashLightStatus = false;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final boolean hasCameraFlash = getPackageManager().
                hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
        boolean isEnabled = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
                == PackageManager.PERMISSION_GRANTED;
        ActivityCompat.requestPermissions(MainActivity.this, new String[] {Manifest.permission.CAMERA}, CAMERA_REQUEST);
        Switch = (ImageButton) findViewById(R.id.Switch);
    Switch.setOnClickListener(new View.OnClickListener() {
            @RequiresApi(api = Build.VERSION_CODES.M)
            @Override
            public void onClick(View view) {
                if (hasCameraFlash) {
                    if (flashLightStatus)
                        flashLightOff();
                    else
                        flashLightOn();
                } else {
                    Toast.makeText(MainActivity.this, "No flash available on your device",
                            Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

    @TargetApi(Build.VERSION_CODES.M)
    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    private void flashLightOn() {
        CameraManager cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);

        try {
            String cameraId = cameraManager.getCameraIdList()[0];
            cameraManager.setTorchMode(cameraId, true);
            flashLightStatus = true;
            Switch.setImageResource(R.drawable.on);
        } catch (CameraAccessException e) {
            Toast.makeText(this,e.toString(),Toast.LENGTH_SHORT).show();
        }
    }

    @RequiresApi(api = Build.VERSION_CODES.M)
    private void flashLightOff() {
        CameraManager cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);

        try {
            String cameraId = cameraManager.getCameraIdList()[0];
            cameraManager.setTorchMode(cameraId, false);
            flashLightStatus = false;
            Switch.setImageResource(R.drawable.off);
        } catch (CameraAccessException e) {
            Toast.makeText(this,e.toString(),Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        switch(requestCode) {
            case CAMERA_REQUEST :
                if (grantResults.length > 0  &&  grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    Switch.setEnabled(true);
                } else {
                    Toast.makeText(MainActivity.this, "Permission Denied for the Camera", Toast.LENGTH_SHORT).show();
                }
                break;
        }
    }
}

Testing our Torch Flashlight Application

Now, it’s time to test our Torch Flashlight Application. You should obtain the following result :