First try this
<style name="CustomAppTheme" parent="AppTheme"> <item name="android:windowContentOverlay">@null</item> </style>
If above solution does not work then do the following in the activity:
ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setElevation(0); }
First you need to add GSON dependency (ref)
compile 'com.google.code.gson:gson:2.2.4'
SharedPreferences sharedPref = getApplicationContext().getSharedPreferences("com.example.myapp.PREFERENCE_FILE_KEY",Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); Gson gson = new Gson(); String jsonMyObject = gson.toJson(myObject); editor.putInt("myObject", jsonMyObject ); editor.commit()
SharedPreferences sharedPref = getApplicationContext().getSharedPreferences("com.example.myapp.PREFERENCE_FILE_KEY",Context.MODE_PRIVATE); Gson gson = new Gson(); String jsonMyObject= mSharedPreferences.getString("myObject", ""); myObject = gson.fromJson(jsonMyObject, MyObject.class);
ArrayList<userModel> userList= new ArrayList<>(); userList.add(new userModel("Jos", "Kuriya")); userList.add(new userModel("Kiran", "Pnr")); Gson gson = new GsonBuilder().create(); JsonArray userJsonArray = gson.toJsonTree(userList).getAsJsonArray(); //Adding data to shared preference SharedPreferences.Editor editor = mSharedPref.edit(); editor.putString("MyUsers", userJsonArray + ""); editor.commit(); //Retrieving data from shared preference String jsonPreferences = mSharedPref.getString("MyUsers", ""); Type type = new TypeToken<ArrayList<userModel>>() {}.getType(); ArrayList<userModel> dataFromSharedPref = gson.fromJson(jsonPreferences, type);
Google drive api does not sync immediately, That is why the deleted folders are still showing, so you have to force google drive to sync using requestSync()
A sample snippet
private MetadataBuffer getGoogleFolders(){ Drive.DriveApi.requestSync(mGoogleApiClient).await(); //Asynchronous request CustomPropertyKey customPropertyKey = new CustomPropertyKey("App", CustomPropertyKey.PRIVATE); Query query = new Query.Builder().addFilter(Filters.and( Filters.eq(SearchableField.TITLE, "My folder"), Filters.eq(SearchableField.TRASHED, false), Filters.eq(customPropertyKey, "sampleApp"))).build(); DriveApi.MetadataBufferResult foldersResult = Drive.DriveApi.query(mGoogleApiClient, query).await(); if (!foldersResult.getStatus().isSuccess()) { Log.i(TAG,"Problem while retrieving results"); return null; } MetadataBuffer result = foldersResult.getMetadataBuffer(); Log.i(TAG, "total result " + result.getCount()); return result; }
OR
//Synchronous request Drive.DriveApi.requestSync(mClient).setResultCallback(new ResultCallback<Status>() { @Override public void onResult(@NonNull Status status) { //search query performs here } });
1. Open your project explorer (this folder structure will not visible in Android explorer)
2. Create a new directory inside res folder name this new directory “layouts”. (This can be whatever you want)
3. create directory tree inside layouts folder (in my example i have created gallery inside layout and values, home ->layout and values, payment ->layout)
4. move your xml files into desired directory (inside layout folder) and delete the old layout folder
5. Add the following code in gradle file (app/build.gradle)
android { - - - - - - - - - - - - - - - - - - - - - - - - - - - sourceSets { main { res.srcDirs = [ 'src/main/res', 'src/main/res/layouts', 'src/main/res/layouts/gallery', 'src/main/res/layouts/home', 'src/main/res/layouts/paymet' ] } } - - - - - - - - - - - - - - - - }
Intent Service Class sample
public class MyIntentService extends IntentService { public static final String Somevariables = "somevalue"; public MyIntentService() { super(MyIntentService.class.getName()); // you can give any string but it is good practice to giving classname } @Override public void onCreate() { super.onCreate(); //--some code -- } @Override protected void onHandleIntent(Intent intent) { //you can retrive intent extras String msg = intent.getStringExtra(EXTRA_KEY); //--actual backgroung code gos here -- } }
Add service in manifest also
<service android:name=".MyIntentService"/>
ref: https://developer.android.com/training/run-background-service/create-service.html
Getting application specific shared preference object
SharedPreferences sharedPref = getApplicationContext().getSharedPreferences("com.example.myapp.PREFERENCE_FILE_KEY",Context.MODE_PRIVATE);
Getting activity specific shared preference object
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit(); //editor.putInt(getString(R.string.saved_high_score), newHighScore); editor.putInt("HIGHSCORE", newHighScore); editor.commit();
//int highScore = sharedPref.getInt(getString(R.string.saved_high_score), defaultValue); int highScore = sharedPref.getInt("HIGHSCORE", defaultValue);