SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
Foreground検知
About me
@kiharekato
Androidエンジニア
Tokyo Otaku Mode Inc.
Activity の Lifecycle にあるだろう
無い。
Applicationにあるんでしょ?
やっぱり無い。
まさか、Task系 !?
/**
* Return a list of the tasks that are currently running, with
** 中略 **
* <p><b>Note: this method is only intended for debugging and presenting
* task management user interfaces</b>. This should never be used for
* core logic in an application, such as deciding between different
* behaviors based on the information found here. Such uses are
* <em>not</em> supported, and will likely break in the future. For
* example, if multiple applications can be actively running at the
* same time, assumptions made about the meaning of the data here for
* purposes of control flow will be incorrect.</p>
*
* @deprecated As of {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method
* is no longer available to third party
* applications: the introduction of document-centric recents means
* it can leak person information to the caller. For backwards compatibility,
* it will still retu rn a small subset of its data: at least the caller's
* own tasks, and possibly some other tasks
* such as home that are known to not be sensitive.
*/
@Deprecated
public List<RunningTaskInfo> getRunningTasks(int maxNum) throws SecurityException {
// 中略
}
ActivityManager.getRunningTasks
/**
* Return a list of the tasks that are currently running, with
** 中略 **
* <p><b>Note: this method is only intended for debugging and presenting
* task management user interfaces</b>. This should never be used for
* core logic in an application, such as deciding between different
* behaviors based on the information found here. Such uses are
* <em>not</em> supported, and will likely break in the future. For
* example, if multiple applications can be actively running at the
* same time, assumptions made about the meaning of the data here for
* purposes of control flow will be incorrect.</p>
*
* @deprecated As of {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method
* is no longer available to third party
* applications: the introduction of document-centric recents means
* it can leak person information to the caller. For backwards compatibility,
* it will still retu rn a small subset of its data: at least the caller's
* own tasks, and possibly some other tasks
* such as home that are known to not be sensitive.
*/
@Deprecated
public List<RunningTaskInfo> getRunningTasks(int maxNum) throws SecurityException {
// 中略
}
ActivityManager.getRunningTasks
!?
/**
* Return a list of the tasks that are currently running, with
** 中略 **
* <p><b>Note: this method is only intended for debugging and presenting
* task management user interfaces</b>. This should never be used for
* core logic in an application, such as deciding between different
* behaviors based on the information found here. Such uses are
* <em>not</em> supported, and will likely break in the future. For
* example, if multiple applications can be actively running at the
* same time, assumptions made about the meaning of the data here for
* purposes of control flow will be incorrect.</p>
*
* @deprecated As of {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method
* is no longer available to third party
* applications: the introduction of document-centric recents means
* it can leak person information to the caller. For backwards compatibility,
* it will still retu rn a small subset of its data: at least the caller's
* own tasks, and possibly some other tasks
* such as home that are known to not be sensitive.
*/
@Deprecated
public List<RunningTaskInfo> getRunningTasks(int maxNum) throws SecurityException {
// 中略
}
ActivityManager.getRunningTasks
!?
!?
Androidでは、
SDK側で提供されて無いじゃね?
public class MyApplication extends Application {
private Timer mActivityTransitionTimer;
private TimerTask mActivityTransitionTimerTask;
public boolean wasInBackground;
private final long MAX_ACTIVITY_TRANSITION_TIME_MS = 2000;
// これをonResumeで実行
public void startActivityTransitionTimer() {
this.mActivityTransitionTimer = new Timer();
this.mActivityTransitionTimerTask = new TimerTask() {
public void run() {
MyApplication.this.wasInBackground = true;
}
};
this.mActivityTransitionTimer.schedule(mActivityTransitionTimerTask, MAX_ACTIVITY_TRANSITION_TIME_MS);
}
  // これをonPauseで実行
public void stopActivityTransitionTimer() {
if (this.mActivityTransitionTimerTask != null) this.mActivityTransitionTimerTask.cancel();
if (this.mActivityTransitionTimer != null) this.mActivityTransitionTimer.cancel();
this.wasInBackground = false;
}
}
http://stackoverflow.com/a/15573121
うーん。微妙じゃね?
Application.ActivityLifecycleCallbacks
Application.ActivityLifecycleCallbacks
UsageStatsManager.queryEvents
UsageStatsManager.queryEvents
簡単に行えないのか?
 画面の構成をFragmentに移すことによって、
ActivityをApplicationと同等の完全単一にすることに
よって、Activity.onResumeでForegroundを取得
できるという計画である。
Activity補完計画
他に良い方法をご存知でしたら、教えてください。
ありがとうございました。

Contenu connexe

Similaire à Foreground検知

F21SC Industrial Programming CW2 Data Analytics (35) 20192.docx
F21SC Industrial Programming CW2 Data Analytics (35) 20192.docxF21SC Industrial Programming CW2 Data Analytics (35) 20192.docx
F21SC Industrial Programming CW2 Data Analytics (35) 20192.docxlmelaine
 
NETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCE
NETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCENETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCE
NETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCEcscpconf
 
CICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your MindCICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your Mindciconf
 
NETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCE
NETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCENETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCE
NETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCEcsandit
 
WEB CRAWLER FOR SOCIAL NETWORK USER DATA PREDICTION USING SOFT COMPUTING METHODS
WEB CRAWLER FOR SOCIAL NETWORK USER DATA PREDICTION USING SOFT COMPUTING METHODSWEB CRAWLER FOR SOCIAL NETWORK USER DATA PREDICTION USING SOFT COMPUTING METHODS
WEB CRAWLER FOR SOCIAL NETWORK USER DATA PREDICTION USING SOFT COMPUTING METHODSAIRCC Publishing Corporation
 
Migration of application schema to windows azure
Migration of application schema to windows azureMigration of application schema to windows azure
Migration of application schema to windows azureeSAT Publishing House
 
Web technology and commerce unit 2
Web technology and commerce unit 2Web technology and commerce unit 2
Web technology and commerce unit 2arun0501
 
No sql injection in meteor.js application
No sql injection in meteor.js applicationNo sql injection in meteor.js application
No sql injection in meteor.js applicationDesignveloper
 
Advanced Module development
Advanced Module developmentAdvanced Module development
Advanced Module developmentdrupalindia
 
Implementation and Evaluation of a Component-Based framework for Internet App...
Implementation and Evaluation of a Component-Based framework for Internet App...Implementation and Evaluation of a Component-Based framework for Internet App...
Implementation and Evaluation of a Component-Based framework for Internet App...ITIIIndustries
 
Drupal Module Development
Drupal Module DevelopmentDrupal Module Development
Drupal Module DevelopmentSumeet Pareek
 
Key aspects of big data storage and its architecture
Key aspects of big data storage and its architectureKey aspects of big data storage and its architecture
Key aspects of big data storage and its architectureRahul Chaturvedi
 
Glutter – A Visual Programming Environment for Complex Event Processing
Glutter – A Visual Programming Environment for Complex Event ProcessingGlutter – A Visual Programming Environment for Complex Event Processing
Glutter – A Visual Programming Environment for Complex Event Processingcscpconf
 
Osgis 2010 notes
Osgis 2010 notesOsgis 2010 notes
Osgis 2010 notesJoanne Cook
 
IJSRED-V2I5P30
IJSRED-V2I5P30IJSRED-V2I5P30
IJSRED-V2I5P30IJSRED
 
People soft workflow by surya 2
People soft workflow by surya 2People soft workflow by surya 2
People soft workflow by surya 2meghamystic
 
Poject documentation deepak
Poject documentation deepakPoject documentation deepak
Poject documentation deepakchetankane
 
Leicester 2010 notes
Leicester 2010 notesLeicester 2010 notes
Leicester 2010 notesJoanne Cook
 
Template based framework for rapid fast development of enterprise applications
Template based framework for rapid fast development of enterprise applicationsTemplate based framework for rapid fast development of enterprise applications
Template based framework for rapid fast development of enterprise applicationseSAT Journals
 

Similaire à Foreground検知 (20)

F21SC Industrial Programming CW2 Data Analytics (35) 20192.docx
F21SC Industrial Programming CW2 Data Analytics (35) 20192.docxF21SC Industrial Programming CW2 Data Analytics (35) 20192.docx
F21SC Industrial Programming CW2 Data Analytics (35) 20192.docx
 
NETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCE
NETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCENETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCE
NETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCE
 
CICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your MindCICONF 2012 - Don't Make Me Read Your Mind
CICONF 2012 - Don't Make Me Read Your Mind
 
NETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCE
NETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCENETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCE
NETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCE
 
WEB CRAWLER FOR SOCIAL NETWORK USER DATA PREDICTION USING SOFT COMPUTING METHODS
WEB CRAWLER FOR SOCIAL NETWORK USER DATA PREDICTION USING SOFT COMPUTING METHODSWEB CRAWLER FOR SOCIAL NETWORK USER DATA PREDICTION USING SOFT COMPUTING METHODS
WEB CRAWLER FOR SOCIAL NETWORK USER DATA PREDICTION USING SOFT COMPUTING METHODS
 
Migration of application schema to windows azure
Migration of application schema to windows azureMigration of application schema to windows azure
Migration of application schema to windows azure
 
Web technology and commerce unit 2
Web technology and commerce unit 2Web technology and commerce unit 2
Web technology and commerce unit 2
 
No sql injection in meteor.js application
No sql injection in meteor.js applicationNo sql injection in meteor.js application
No sql injection in meteor.js application
 
Spring batch
Spring batchSpring batch
Spring batch
 
Advanced Module development
Advanced Module developmentAdvanced Module development
Advanced Module development
 
Implementation and Evaluation of a Component-Based framework for Internet App...
Implementation and Evaluation of a Component-Based framework for Internet App...Implementation and Evaluation of a Component-Based framework for Internet App...
Implementation and Evaluation of a Component-Based framework for Internet App...
 
Drupal Module Development
Drupal Module DevelopmentDrupal Module Development
Drupal Module Development
 
Key aspects of big data storage and its architecture
Key aspects of big data storage and its architectureKey aspects of big data storage and its architecture
Key aspects of big data storage and its architecture
 
Glutter – A Visual Programming Environment for Complex Event Processing
Glutter – A Visual Programming Environment for Complex Event ProcessingGlutter – A Visual Programming Environment for Complex Event Processing
Glutter – A Visual Programming Environment for Complex Event Processing
 
Osgis 2010 notes
Osgis 2010 notesOsgis 2010 notes
Osgis 2010 notes
 
IJSRED-V2I5P30
IJSRED-V2I5P30IJSRED-V2I5P30
IJSRED-V2I5P30
 
People soft workflow by surya 2
People soft workflow by surya 2People soft workflow by surya 2
People soft workflow by surya 2
 
Poject documentation deepak
Poject documentation deepakPoject documentation deepak
Poject documentation deepak
 
Leicester 2010 notes
Leicester 2010 notesLeicester 2010 notes
Leicester 2010 notes
 
Template based framework for rapid fast development of enterprise applications
Template based framework for rapid fast development of enterprise applicationsTemplate based framework for rapid fast development of enterprise applications
Template based framework for rapid fast development of enterprise applications
 

Dernier

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 

Dernier (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

Foreground検知

  • 3. Activity の Lifecycle にあるだろう
  • 8. /** * Return a list of the tasks that are currently running, with ** 中略 ** * <p><b>Note: this method is only intended for debugging and presenting * task management user interfaces</b>. This should never be used for * core logic in an application, such as deciding between different * behaviors based on the information found here. Such uses are * <em>not</em> supported, and will likely break in the future. For * example, if multiple applications can be actively running at the * same time, assumptions made about the meaning of the data here for * purposes of control flow will be incorrect.</p> * * @deprecated As of {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method * is no longer available to third party * applications: the introduction of document-centric recents means * it can leak person information to the caller. For backwards compatibility, * it will still retu rn a small subset of its data: at least the caller's * own tasks, and possibly some other tasks * such as home that are known to not be sensitive. */ @Deprecated public List<RunningTaskInfo> getRunningTasks(int maxNum) throws SecurityException { // 中略 } ActivityManager.getRunningTasks
  • 9. /** * Return a list of the tasks that are currently running, with ** 中略 ** * <p><b>Note: this method is only intended for debugging and presenting * task management user interfaces</b>. This should never be used for * core logic in an application, such as deciding between different * behaviors based on the information found here. Such uses are * <em>not</em> supported, and will likely break in the future. For * example, if multiple applications can be actively running at the * same time, assumptions made about the meaning of the data here for * purposes of control flow will be incorrect.</p> * * @deprecated As of {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method * is no longer available to third party * applications: the introduction of document-centric recents means * it can leak person information to the caller. For backwards compatibility, * it will still retu rn a small subset of its data: at least the caller's * own tasks, and possibly some other tasks * such as home that are known to not be sensitive. */ @Deprecated public List<RunningTaskInfo> getRunningTasks(int maxNum) throws SecurityException { // 中略 } ActivityManager.getRunningTasks !?
  • 10. /** * Return a list of the tasks that are currently running, with ** 中略 ** * <p><b>Note: this method is only intended for debugging and presenting * task management user interfaces</b>. This should never be used for * core logic in an application, such as deciding between different * behaviors based on the information found here. Such uses are * <em>not</em> supported, and will likely break in the future. For * example, if multiple applications can be actively running at the * same time, assumptions made about the meaning of the data here for * purposes of control flow will be incorrect.</p> * * @deprecated As of {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method * is no longer available to third party * applications: the introduction of document-centric recents means * it can leak person information to the caller. For backwards compatibility, * it will still retu rn a small subset of its data: at least the caller's * own tasks, and possibly some other tasks * such as home that are known to not be sensitive. */ @Deprecated public List<RunningTaskInfo> getRunningTasks(int maxNum) throws SecurityException { // 中略 } ActivityManager.getRunningTasks !? !?
  • 12.
  • 13. public class MyApplication extends Application { private Timer mActivityTransitionTimer; private TimerTask mActivityTransitionTimerTask; public boolean wasInBackground; private final long MAX_ACTIVITY_TRANSITION_TIME_MS = 2000; // これをonResumeで実行 public void startActivityTransitionTimer() { this.mActivityTransitionTimer = new Timer(); this.mActivityTransitionTimerTask = new TimerTask() { public void run() { MyApplication.this.wasInBackground = true; } }; this.mActivityTransitionTimer.schedule(mActivityTransitionTimerTask, MAX_ACTIVITY_TRANSITION_TIME_MS); }   // これをonPauseで実行 public void stopActivityTransitionTimer() { if (this.mActivityTransitionTimerTask != null) this.mActivityTransitionTimerTask.cancel(); if (this.mActivityTransitionTimer != null) this.mActivityTransitionTimer.cancel(); this.wasInBackground = false; } } http://stackoverflow.com/a/15573121
  • 15.