Detecting-An-App-is-onPause-or-onResumeGoAsiaToday Icon

Location Tracker
Location Tracker
Keep tracking & Recording
your movement


Simple Budget
Simple Budget
Set a budget, recording daily expenditure, keep spending under budget to achieve saving goal.


Detecting An App is onPause or onResume
AndroidApps
13 January,17 14:16

When we build an app, we need to consider what should the app do if it is paused or reversely. So, how can we know the app is paused or resumed? There is a simple method to know it. 

Firstly, we need to create onResume() and onPause() methods, when the app is paused, the onResume() will be called automatically, it is the same story on onPause() method. Then, create a log() method. When either onPause() or onResume() is called, the log method will be called with the parameter value. After the log method received the parameter value, the parameter value will be shown through StringBuilder. The textView is for showing the app status. Thus, the StringBuilder is set into textView.

The example codes are shown as below:
public class MainActivity extends AppCompatActivity {

StringBuilder builder = new StringBuilder();
TextView textView;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

textView=new TextView(this);
textView.setText(builder.toString());
setContentView(textView);
log("created");

}
@Override
protected void onResume(){
super.onResume();
log("resumed");
}
@Override
protected void onPause(){
super.onResume();
log("paused");
if(isFinishing()){
log("finishing");
}
}

private void log(String text){

Log.d("MainActivity",text);
builder.append(text);
builder.append("n");
textView.setText(builder.toString());

}

}


PhotoScan
AndroidApps

Wow! I really like Google's New App called PhotoScan. It provides an easiest way to convert physical photos into digital ones with high quality.



Zombie Corps
AndroidApps

A zombie apocalypse has been unleashed upon the earth. Led by General Koch and his mutating zombie army, humans are on the fast train to extinction...



Displaying Recorded Routes With Actual Received GPS Data
AndroidApps

The reason for "My Place" (Android App) to use actual received GPS Data to form recorded routes, rather than estimating movement with Google's Navigator.



My Place
AndroidApps

Location Tracker



My Place
AndroidApps

My New Android App for location tracking



Caption Fun
AndroidApps

Design your grid images and add meaningful captions.




Android Apps
Location Tracker
Location Tracker
Keep tracking & Recording
your movement


Money Monitor
Money Monitor
Recording your daily expenditure
to meet your budget.
Simple Budget
Simple Budget
Keep spending under budget
to achieve saving goal.
Caption Fun
Caption Fun
Combining serveral photos into one


BACK

Copyright © GoAsiaToday.com

Today:143 Total:2797500 Total Article:1786
 Since 30 March 2016  



Admin Only