Last active
April 14, 2021 02:44
-
-
Save simlegate/5545512 to your computer and use it in GitHub Desktop.
Revisions
-
simlegate revised this gist
May 9, 2013 . 1 changed file with 33 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.simlegate.saveresource" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <receiver android:name=".ScreenActionReceiver"> <intent-filter android:priority="90000"> <action android:name="android.intent.action.USER_PRESENT" /> </intent-filter> </receiver> </application> </manifest> -
simlegate revised this gist
May 9, 2013 . 1 changed file with 45 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ package com.simlegate.saveresource; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.util.Log; public class ScreenActionReceiver extends BroadcastReceiver { private String TAG = "ScreenActionReceiver"; @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if(Intent.ACTION_SCREEN_ON.equals(action)) { Log.d(TAG, "screen is on..."); } else if(Intent.ACTION_SCREEN_OFF.equals(action)) { Log.d(TAG, "screen is off..."); } else if(Intent.ACTION_USER_PRESENT.equals(action)) { Log.d(TAG, "screen is unlock..."); } } public IntentFilter getFilter(){ final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_ON); return filter; } } -
simlegate created this gist
May 9, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ package com.simlegate.saveresource; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ScreenActionReceiver screenactionreceiver = new ScreenActionReceiver(); registerReceiver(screenactionreceiver, screenactionreceiver.getFilter()); } }