Warning : Do not hardcode “/data/”; use Context.getFilesDir().getPath() instead

I developed an application in which I copied the database from the assets folder to my path which is hardcoded. So eclipse gives me warning : Do not hardcode “/data/”; use Context.getFilesDir().getPath() instead I searched in google and found the answer as to use : Context.getFilesDir().getPath(); And the hard coding is not working on every […]

OkHttp in android for making network requests

What I am trying to do:: I am trying to learn the usage of Okhttp for making networking calls in android What I have done:: I have read their documentation here I have downloaded and added the JAR in the project I am using their sample code from here MyCode:: MainActivity.java import android.app.Activity; import android.os.Bundle; […]

Security with SharedPreferences

I am developing an application in which I have to store very sensitive data and it should not come in contact with the user. I got to know from this source that if a device is rooted then accessing SharedPreferences and modifying it is a cakewalk. And I don’t want it. So is there any […]

Stop images on sd card from showing up in gallery?

I keep some png files on the user’s sd card. Some users report that these images are showing up in their gallery application. Sounds like the gallery implementation on some devices search out any image files they can find on the sd card and show it in the gallery. Is there a way to tell […]

How to close the activity from the service?

I am launching activity from the service based on some value got from the server and the activity will be displayed for the some time and after getting close instruction from the server i need to close that activity,so for that i used following approach but it’s not working: on Service class: if(((ActivityManager)this.getSystemService(ACTIVITY_SERVICE)).getRunningTasks(1).get(0).topActivity.getPackageName().equals(“com”)) { if(((ActivityManager)this.getSystemService(ACTIVITY_SERVICE)).getRunningTasks(1).get(0).topActivity.getClassName().equals(“com.CustomDialogActivity”)){ […]

SMSMessage createFromPdu with extra parameter format

What should I pass as second parameter<“format”> to createFromPdu() method, SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i], format); As in latest version of android following line of code is deprecated, SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]); I have searched on Internet but nothing was clear to me. I have read into android doc too, http://developer.android.com/reference/android/telephony/SmsMessage.html#createFromPdu(byte[], java.lang.String)

Android 6(M) permission issue (create directory not working)

I have this code for creating directory for saving pictures: File storageDir = null; if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), “myphoto”); if (!storageDir.mkdirs()) { if (!storageDir.exists()){ Log.d(“photo”, “failed to create directory”); return null; } } } return storageDir; storeDir returns “/storage/emulated/0/Pictures/myphoto/” below android 6 and on android 6 it returns null. I have permission […]

Draw dash line on a Canvas

How can i draw dash line on a canvas. I already tried this: Paint dashPaint = new Paint(); dashPaint.setARGB(255, 0, 0, 0); dashPaint.setStyle(Paint.Style.STROKE); dashPaint.setPathEffect(new DashPathEffect(new float[]{5, 10, 15, 20}, 0)); canvas.drawLine(0, canvas.getHeight() / 2, canvas.getWidth(), canvas.getHeight() / 2, dashPaint); And it gave me not dash line but a simple one.

How to select multiple images from gallery in android?

I am making a project in which i want to select multiple photos from gallery and want to save that in imageview array. I am able to import single image and save at imageview Can anyone tell please how may i import multiple images and save in array or different imageviews? MainActivity extends Activity implements […]

Android TextView Background

i have a design which demands a background like the image below for the number on the right hand side. Is there any we can achieve this in Android ? Will i need to make a 9 patch image and set it as a background ?

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.