Tuesday, 19 July 2016

Custom Kestore to upload signed APK for Playstore using SHA1

Usually when  create the google map it will run proper in locally after setting google key ,package name and SHA1 certificate fingerprint

when upload the APK to play store we have to create custom keystore, then only we will be able to upload playstore
 here when change the keystore default into custom obviously SHA1 fingerprint also will get changed
so we have to try change in eclipse


here or we can try

C:\Users\**********>keytool -list -keystore D:\APK\Keystore\oneapp.keystore
Enter keystore password:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

oneapp, Jul 19, 2016, PrivateKeyEntry,
Certificate fingerprint (SHA1): CF:64:96:E5:A9:F9:EF:70:6F:7D:18:2B:54:36:E5:7D:
A8:5F:7A:99







There is other way of doing as follow here


Steps (for ADT):
1.Export any project (It will show you an option to create custom keystore).
enter image description here
create your keystore with an extention ".keystore" and give password android and press next.
2.enter image description here
give alias name = androiddebugkey and password = android
now press finish and your keystore is ready.
1.Go to windows -> preference
and give the path of your custom keystore file
enter image description here





Monday, 7 December 2015

Android/SCREEN ON, SCREEN OFF BroadcastReceiver

public class MyApplication extends Application {
    public static final String TAG = "SCREEN";
 
    private BroadcastReceiver scrOnReceiver;
    private BroadcastReceiver scrOffReceiver;
    private IntentFilter scrOnFilter;
    private IntentFilter scrOffFilter;
 
    @Override
    public void onCreate() {
        super.onCreate();
 
        scrOnReceiver = new BroadcastReceiver() { 
            @Override 
            public void onReceive(Context context, Intent intent) { 
                Log.d(TAG, "SCREEN ON"); 
  timer.cancel();
            } 
        };
 
        scrOnFilter = new IntentFilter(Intent.ACTION_SCREEN_ON); 
 
        scrOffReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                Log.d(TAG, "SCREEN OFF");
  timer.start();
            }
        };
 
        scrOffFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
 
        registerReceiver(scrOnReceiver, scrOnFilter);
        registerReceiver(scrOffReceiver, scrOffFilter);
    }

//time counting
 CountDownTimer timer = new CountDownTimer(1*60*1000, 1000) {

        public void onTick(long millisUntilFinished) {
           //Some code
         Log.d("timer", "--"+millisUntilFinished);
         
        }

        public void onFinish() {
           //Logout
         Intent intent=new Intent(AppController.this,LoginActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

         Log.d("***********", "logout");
        }
     };
 
    @Override
    public void onTerminate() {
        super.onTerminate();
 
        unregisterReceiver(scrOnReceiver);
        unregisterReceiver(scrOffReceiver);
    }
 
}




<uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
 
    <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
   </application>

Tuesday, 24 November 2015

Android application logout after 15 min

Here i just made the code the application should come out when it is not used till 15 minutes

for counting i have taken counter


CountDownTimer timer = new CountDownTimer(15 *60 * 1000, 1000) {

       public void onTick(long millisUntilFinished) {
          //Some code
        Log.d("timer", "--"+millisUntilFinished);
       }

       public void onFinish() {
          //Logout
        finish();
        Log.d("***********", "logout");
       }
    };


then i just calling the timer when it goes to sleep

@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
Log.d("***********", "onPause");
timer.start();
}



meanwhile if the application started again it means like resume, it should cancel

 @Override protected void onResume()
{ Log.d("***********", "onresume");
 super.onResume(); timer.cancel();
 }


Wednesday, 18 November 2015

Android set image in imageview from mysql blob


php code for getting blob type from databse


$product["description"] = $row["description"];
$product["before_tuning_graph"] = base64_encode($row['before_tuning_graph']);
$product["after_tuning_graph"] = base64_encode($row['after_tuning_graph']);





In java 

read the blob images as string 

//setting image for before tuning
try {
byte[] res1 = Base64.decode(arrayList.get(position).getBefore_tuning_graph(), 0);
    InputStream ins =new ByteArrayInputStream(res1);
    Drawable dUser = Drawable.createFromStream(ins , "immagine");
    imageViewBefore.setImageDrawable(dUser);
    
} catch (Exception e) {
e.printStackTrace();
}


Wednesday, 11 November 2015

Store ArrayList in android SharedPreference

ArrayList<String> myArrayList=new ArrayList<String>();

myArrayList.add("value1");
myArrayList.add("value2");
myArrayList.add("value3");
myArrayList.add("value4");
myArrayList.add("value5");
myArrayList.add("value6");

Store arraylist in sharedpreference

SharedPreference sPrefs=PreferenceManager.getDefaultSharedPreferences(context);
SharedPreference.Editor sEdit=sPrefs.edit();

for(int i=0;i<myArrayList.size();i++)
{
         sEdit.putString("val"+i,myArrayList.get(i);
}
 sEdit.putInt("size",myArrayList.size());
 sEdit.commit();

Retrive arraylist from sharedpreference

I am retriving values in another arraylist

ArrayList<String> myAList=new ArrayList<String>();
int size=sPrefs.getInt("size",0);

for(int j=0;j<size;j++)
{
          myAList.add(sPrefs.getString("val"+j));
}