Skip to content

Instantly share code, notes, and snippets.

View umarpazir11's full-sized avatar

Umer umarpazir11

View GitHub Profile
@umarpazir11
umarpazir11 / Clear All Activity Stack In Android
Created November 8, 2016 06:55
Normally when we launch new activity, it’s previous activities will be kept in a queue like a stack of activities. So if you want to kill all the previous activities, just follow these methods.
Intent i = new Intent(OldActivity.this, NewActivity.class);
// set the new task and clear flags
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
startActivity(i);
@umarpazir11
umarpazir11 / Auto Generate Comments
Last active November 8, 2016 06:42
If you want to write comments for your android functions, there is an easy way to auto generate the basic comment skeleton in Android Studio. First define you function with all the necessary parameters and a return value. Then keep the cursor above the function, type /** and press Enter key. You can see the required will be generate above your f…
Keep the cursor above the function, type /** and press Enter key.
/**
*
* @param title
* @param isValid
* @param listNames
* @return
*/
private boolean shouldGenerateAutoComments(String title, boolean isValid, List<String> listNames){
// function code