Today i am going to explain Android SharedPreferences.
Android SharedPreferences:
Android supports the usage of the SharedPreferences class for persisting key-value pairs (preferences)of primitive data types in the Android file system.
The definition of these preferences can be done via an XML resource.
The PreferenceManager class provides methods to get access to preferences stored in a certain file.
Step to Create SharedPreference:-
1. create object of SharedPreference in following way.
Hi Friend We know that Phone Gap provide facility to create Hybrid (cross plat form) application. In phonegap we create application using HTMLt5, CSS3 and JavaScript.
Now i am going to explain how to create simple android phone gap exaple application using eclipse IDE.
Step 1: First of all download phonegap SDK and extract Director structure like this.
click on lib
click on andorid
Now create an android application:
1. create www name folder in assets folder. 2. create index.html file with www folder that created previously. 3. Copy from \phonegap-2.3.0\lib\android\ cordova-2.3.0.js file and patse in www folder. 4.Copy from \phonegap-2.3.0\lib\android\cordova-2.3.0.jar file and paste in project lib folder and add to build path. 5. Copy from \phonegap-2.3.0\lib\android\xml folder and paste it into res folder.
Now your project file directory structure look like this.
Dear Friend In this post i have explain knowledge about phone-gap application using Android. It is very simple. But first of all i want write some information about phone-gap.
1. What is phone gap?
ans: phone is an open-source mobile application development framework,that offers programmers to build applications for mobile devices using JavaScript, HTML 5, and CSS 3, instead of device-specific languages such as Objective-C
2. What are characteristic of phone gap?
ans: The phone-gap application characteristic : The resulting applications are hybrid, meaning that they are neither truly native (because all layout rendering is done via web views instead of the platform's native UI framework) nor purely web-based (because they are not just web apps, but are packaged as apps for distribution and have access to native device APIs). Conclusion about Phone-gap: phone-gap facilitate us to write cross platform mobile application.
Android provide text to speech class. using this class we can easily create an message reader type application, using the method of this class we can control speed of narrating and sound pitch also.
Today i am going to explain Image Switcher example.
Image Switcher is similar to imageView but image switcher is a element of Transition Widget. so, here we display image with some animated style. In image switcher image view create at run time and if i want then we also add some animation.
Code Discription:-
java source code:-
package in.androidshivendraimageswitcherexample;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation;
import android.widget.Button;
import android.widget.ImageSwitcher;
import android.widget.ImageView;
import android.widget.Toast;
import android.widget.ViewSwitcher.ViewFactory;
public class ImageSwitcherExampleActivity extends Activity implements ViewFactory{
ImageSwitcher is;
int [] imgid = {R.drawable.shivendra,R.drawable.krishna,R.drawable.madina,R.drawable.sai,R.drawable.sambhu,R.drawable.tirupati};
// First check if device is supporting flashlight or not
hasFlash = getApplicationContext().getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
if (!hasFlash) {
// device doesn't support flash
// Show alert message and close the application
AlertDialog alert = new AlertDialog.Builder(MainActivity.this)
.create();
alert.setTitle("Error");
alert.setMessage("Sorry, your device doesn't support flash light!");
alert.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// closing the application
finish();
}
});
alert.show();
return;
}
// get the camera
getCamera();
}
// Get the camera
private void getCamera() {
if (camera == null) {
try {
camera = Camera.open();
params = camera.getParameters();
} catch (RuntimeException e) {
Log.e("Camera Error. Failed to Open. Error: ", e.getMessage());
}
}
}
// Turning On flash
private void turnOnFlash() {
if (!isFlashOn) {
if (camera == null || params == null) {
return;
}
// on stop release the camera
if (camera != null) {
camera.release();
camera = null;
}
}
@Override public void onAccuracyChanged(Sensor sensor, int accuracy) { // TODO Auto-generated method stub }
@Override public void onSensorChanged(SensorEvent event) { // TODO Auto-generated method stub if (event.values[0]<5 .0="" p="">{
// turn on flash
turnOnFlash();
Hi Friend
Today i am going to explain how to upload image on application server using android.
There are two part for creating such type application.
1. Server part
2.android application creation
Server Part :
To work with Application Server you required knowledge about server programming language (like jsp, php, Asp etc). i have used PHP script.
Step 1:
Open any text editor and write php script code that written below and save with index.php and also create a folder named uploads location C:\xampp\htdocs\
/************* Php script path ****************/
upLoadServerUri = "http://10.0.2.2/index.php"; // here 10.0.2.2 is url for local server when you run on emulator.
uploadButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {