Skip to main content

Posts

Showing posts from 2011

Playing wav File in android using Audio Track

To play a wav file read the wav file and pass the bytes to audio track chunck by chunk. private void playWaveFile(){                 // define the buffer size for audio track         int minBufferSize = AudioTrack.getMinBufferSize(8000, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT);         int bufferSize = 512;         AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_VOICE_CALL, 8000, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, minBufferSize, AudioTrack.MODE_STREAM);         String filepath = "File Path";         int count = 0;         byte[] data = new byte[bufferSize];         try {             FileInputStream fileInputStream = new FileInputStream(filepath);             DataInputStream dataInputStream = new DataInputStream(fileInputStream);             audioTrack.play();                         while((count = dataInputStream.read(data, 0, bufferSize)) > -1){                 audioTrack.write(data, 0, count);

How to Uninstall the ANDROID App through Java Code...

We can uninstall an installed application on your  Android device. Steps- 1. Create an intent object with an action ACTION_DELETE. 2. Give the data as the package name.  and , // Code to uninstall the app Intent intent = new Intent(Intent.ACTION_DELETE); intent.setData(Uri.parse("package:com.package.Appname")); startActivity(intent);

Retrive Platform information for android device programatically

There are some useful methods to retrieve the platform related information of the device programmatic ally   Method to get the manufacturer of the device      /**      * Get the Manufacturer of the Device      * @return String      */     public String getManufacurer(){         return android.os.Build.MANUFACTURER;     }    Method to get the device model     /**      *  Get the Model of the Device      * @return String      */     public String getModel(){         return android.os.Build.MODEL;     }   Method  to get the OS build number      /**      * Get the Build Number of the OS      * @return String      */     public String getOSBuildNumber(){         return android.os.Build.DISPLAY;     }      Using Telephony Manager:- TelephonyManager mTelephonyMgr = null; You do not instantiate this class directly; you can retrieve a reference to an instance through mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.