Posts

Android navigation

Providing Up Navigation The up navigation will allow our application to move to previous activity from the next activity. It can be done like this. To implement Up navigation, the first step is to declare which activity is the appropriate parent for each activity. You can do it by specifying  parentActivityName  attribute in an activity. Its syntax is given below − android:parentActivityName = "com.example.test.MainActivity" After that you need to call  setDisplayHomeAsUpEnabled  method of  getActionBar()  in the onCreate method of the activity. This will enable the back button in the top action bar. getActionBar (). setDisplayHomeAsUpEnabled ( true ); The last thing you need to do is to override  onOptionsItemSelected  method. when the user presses it, your activity receives a call to onOptionsItemSelected(). The ID for the action is  android.R.id.home .Its syntax is given below − public boolean onOptionsItemSelected ( MenuIt...

SQlite database in android

Application:->java->package->new->java class file-> mydatabase.java import  java.util.ArrayList ;  /**  * Created by Rahul on 15-Jul-16.  */  public class  mydatabase  extends   SQLiteOpenHelper {//SQLiteOpenHelper=inbuilt class      public static final  String  table_name  =  “college_details” ;      public static final  String  column_college_id  =  “id” ;      public static final  String  column_college_name  =  “name” ;      public static final  String  db_name  =  “ptu” ;      public static final int  db_version  = 1;      public static final  String  query_create  =  “create table ”  +  table_name  +  ” ( ”  +  column_college_id  +  ” Integer(10) prim...

Introduction to Android Networking, Client Server

Android lets your application connect to the internet or any other local network and allows you to perform network operations. A device can have various types of network connections. This chapter focuses on using either a Wi-Fi or a mobile network connection. Checking Network Connection Before you perform any network operations, you must first check that are you connected to that network or internet e.t.c. For this android provides  ConnectivityManager  class. You need to instantiate an object of this class by calling  getSystemService()  method. Its syntax is given below − ConnectivityManager check = ( ConnectivityManager ) this . context . getSystemService ( Context . CONNECTIVITY_SERVICE ); Once you instantiate the object of ConnectivityManager class, you can use  getAllNetworkInfo  method to get the information of all the networks. This method returns an array of  NetworkInfo . So you have to receive it like this. NetworkInfo [] ...

Android - Notifications

Image
A  notification  is a message you can display to the user outside of your application's normal UI. When you tell the system to issue a notification, it first appears as an icon in the notification area. To see the details of the notification, the user opens the notification drawer. Both the notification area and the notification drawer are system-controlled areas that the user can view at any time. Android  Toast  class provides a handy way to show users alerts but problem is that these alerts are not persistent which means alert flashes on the screen for a few seconds and then disappears. To see the details of the notification, you will have to select the icon which will display notification drawer having detail about the notification. While working with emulator with virtual device, you will have to click and drag down the status bar to expand it which will give you detail as follows. This will be just  64 dp  tall and called normal view. Abov...

Android Content Provider(Easy explaination with diagram)

Image
A content provider component supplies data from one application to others on request. Such requests are handled by the methods of the ContentResolver class. A content provider can use different ways to store its data and the data can be stored in a database, in files, or even over a network. Content providers let you centralize content in one place and have many different applications access it as needed. A content provider behaves very much like a database where you can query it, edit its content, as well as add or delete content using insert(), update(), delete(), and query() methods. In most cases this data is stored in an  SQlite  database. A content provider is implemented as a subclass of  ContentProvider  class and must implement a standard set of APIs that enable other applications to perform transactions. Create Content Provider This involves number of simple steps to create your own content provider. First of all you need to create a Content P...

My text editor using file handling

set access in manifeast file set access in emulator app drag->app info->set permissions Manifeast File <? xml version= “1.0”  encoding= “utf-8” ?>  < manifest  xmlns: android = “ http://schemas.android.com/apk/res/android&#8221 ;      package= “ com.myapp.mytexteditor ” >     < uses-permission  android :name= “android.permission.WRITE_EXTERNAL_STORAGE” /> Activity package  com.myapp.mytexteditor ;  import  android.content.Intent;  import  android.os.Environment ;  import  android.support.v7.app.AppCompatActivity ;  import  android.os.Bundle ;  import  android.view.View ;  import  android.widget.EditText;  import  android.widget.TextView;  import  android.widget.Toast ;  import  java.io.BufferedReader ;  import  java.io.BufferedWriter ;  import  java.io.File ;  import  java...