Skip to main content

Posts

Showing posts with the label android

Save data using SharedPreferences in Android

Hello           Today we are going to save any type of data using sharePreferances in android mobile. Step-1 Make a new android app. if you don't know how to do that then Read this post. Step-2 Just drag and drop Edit Text and 2 Buttons into virtual mobile GUI as shown in figure. Step-3 Just Copy and paste following code before onCreate method SharedPreferences sharedPref; SharedPreferences.Editor editor; now just copy and paste following code into onCreate method sharedPref = MainActivity.this.getSharedPreferences("xyz", Context.MODE_PRIVATE); editor=sharedPref.edit(); final EditText editText=(EditText) findViewById(R.id.editText); Button btn=(Button) findViewById(R.id.button); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub editor.putString("city", String.valueOf(editText)); editor.commit(); } }); Button btn2=(Button) findViewById(R.id.button2); btn2.se...

How to take raw data from an android mobile phone's GPS..?

Hello friends                         Today i am gonna to discuss about taking raw data or coordinate from an android mobile GPS device. Let's Start................ Step:1 Just enter into programming mode in android studio. If you don't know that how to do that please read this post. Step:2 Now just make a new class as show in figure and name it BootService. Step:3 Now extends Service and implements LocationListener as shown in figure below. Step:4 Now just copy and paste following code into BootService class. LocationManager lm; @Override public int onStartCommand(Intent intent, int flags, int startId) { lm = (LocationManager) getSystemService(LOCATION_SERVICE); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 1, this); return START_STICKY; } @Override public void onLocationChanged(Location location) { try{ Toast.makeText(this, "GPS Values Found: " + String.va...

How to show dialog box in android programmatically.............!

Hello friends Today i am going to tell"how to  show a dialog box in notification bar programmatically". Let's Start........... Step:1 First you have to open android studio in development mode of app. If you don't know how to do that then read this post. Step:2 Just drag and drop 2 buttons into virtual mobile and rename buttons as Dialog On and Dialog Off. Step:3 Just copy and paste following code before OnCreate method.... static NotificationManager mNotifyManager; static NotificationCompat.Builder mBuilder; Now just copy & paste given code below into OnCreate method.... Button on=(Button) findViewById(R.id.button); Button off=(Button) findViewById(R.id.button2); on.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mBuilder = new NotificationCompat.Builder(MainActivity.this); mBuilder.set...

How to take raw data from gyroscope in android.......................!!!!

Hello friends The gyroscope, or gyro for short, adds an additional dimension to the information supplied by the accelerometer by tracking rotation or twist. An accelerometer measures linear acceleration of movement, while a gyro on the other hand measures the angular rotational velocity.                                                                                            Every smart mobile phone has various sensor in built.Today we are going to learn "How to take data from mobile gyroscope". Let's start............... Step:1 Just open android studio and click on make new project.Now enter into programming/Development mode. If you don't know how to do that then go to this tutorial. Step:2 Now just drag and drop 3 tax view into virtu...

How to control Bluetooth Programmatically ...........!

It is very important many time to control bluetooth programmatically, so i have come with this post"How to control Bluetooth Programmatically ...........!" let's start..... Step:1 Enter in app development mode in Android Studio. if you don't know how to do that then read this post. Step:2 Now just drag & drop button into virtual mobile screen as shown in figure below..... Step:3 now just double click on dragged buttons and rename them as "On" and "Off". Step:4 Now copy & paste following permission into manifest file. <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> Step:5 just copy and paste following code outside the OnCreate method: ArrayAdapter<BluetoothDevice> mArrayAdapter; BluetoothAdapter mbt; ArrayList<String> arr=new ArrayList<String>(); ArrayLis...

How to import an image in android app...?

Hello friends in this post i am going to show ,how to display an image in android app. let's start .............. For the initial setup see my blog  How to make first android app..? Step-1: Just drag and drop the image view into virtual mobile as shown in figure. Step-2: Now copy the image which you want to import app and paste in drawable folder in upper-left side. Step-3: Now double click on image view which you draged and droped into virtual mobile. Now select src and select that image and click ok. Step-4: Now you can see image in your virtual mobile.Just plug mobile into PC and click on run button in android studio. For any query comment below.

How to make first android app....!

Welcome to Android application development! This class teaches you how to build your first Android app. You’ll learn how to create an Android project. You'll also learn some fundamentals of Android app design, including how to build a simple user interface and handle user input. Set Up Your Environment you will need following things for making android app. A computer or laptop having android studio installed on it. A little knowledge of Java programming. Basic knowledge of Android studio. latest version of JDK (java development kit) and JRE installed on pc. Create a Project with Android Studio In Android Studio, create a new project: If you don't have a project opened, in the  Welcome  screen, click  New Project . If you have a project opened, from the  File  menu, select  New Project . The  Create New Project  screen appears. Fill out the fields on the screen, and click  Next . It is easier to follo...