Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added wake lock to TalkActivity will permanently stay on

  • Loading branch information...
commit 1a6d8fb125c3e07126afdb0e396737e0a88ac381 1 parent d47cd82
Sam Karp authored
View
1  android/AndroidManifest.xml
@@ -48,5 +48,6 @@
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>
View
8 android/src/gov/nasa/arc/geocam/talk/activity/GeoCamTalkActivity.java
@@ -20,6 +20,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
+import android.os.PowerManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
@@ -67,11 +68,16 @@ public void onReceive(Context context, Intent intent) {
}
}
};
+
+ private PowerManager.WakeLock wakeLock;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
+ PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
+ wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "DimScreenALittle");
+
}
private void populateListView() {
@@ -131,6 +137,7 @@ public void newMessages() {
@Override
protected void onResume() {
super.onResume();
+ wakeLock.acquire();
IntentFilter filter = new IntentFilter();
filter.addAction(TalkServerIntent.INTENT_NEW_MESSAGES.toString());
registerReceiver(receiver, filter);
@@ -158,6 +165,7 @@ public void onItemClick(AdapterView<?> parentView, View childView,
@Override
protected void onPause() {
unregisterReceiver(receiver);
+ wakeLock.release();
super.onPause();
}
}
View
2  android/src/gov/nasa/arc/geocam/talk/activity/GeoCamTalkCreateActivity.java
@@ -18,9 +18,11 @@
import roboguice.activity.RoboActivity;
import roboguice.inject.InjectResource;
import roboguice.inject.InjectView;
+import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
Please sign in to comment.
Something went wrong with that request. Please try again.