Skip to content

Topic breakout lock screen #596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4907b49
アプリが bg にいても JS のコールバックを呼び出すように変更。
Jun 23, 2015
47e855c
android.suport.v13 を使用しないように変更。
Jun 23, 2015
35133b0
android-support-v13.jar に含まれている v4 とオリジナルの android-support-v4 が
Jul 3, 2015
3183303
Merge pull request #1 from Nextremer/topic-notification-v4
Jul 3, 2015
284c00f
APIサーバからのGeolocation情報取得要求に HttpRequest で応答する機能を実装した。
Jul 7, 2015
bfaa5e8
Merge pull request #2 from Nextremer/topic-request-geolocation
Jul 7, 2015
aae0a96
onError() メソッドを間違えて消していた。
Jul 7, 2015
58dc703
Merge branch 'master' of github.com:Nextremer/PushPlugin into topic-r…
Jul 7, 2015
029db42
Merge pull request #3 from Nextremer/topic-request-geolocation
Jul 7, 2015
6bb3126
HttpRequest の終了ステータス判定を 200 番台は成功とみなすように修正した。
Jul 7, 2015
59d8e81
Merge pull request #4 from Nextremer/topic-request-geolocation
Jul 7, 2015
a810fb1
バイブレーションのパターンとアイコンを GCM のペイロードで伝えるように実装した。
Jul 8, 2015
e0d2f1c
Merge pull request #5 from Nextremer/topic-long-vibration
Jul 8, 2015
0014c4c
テキスト表示対応。
Jul 8, 2015
2600e47
Merge pull request #6 from Nextremer/topic-long-vibration
Jul 8, 2015
0a7cd8d
ポップアップダイアログ実装。スクリーンロック突破は未実装。
Jul 10, 2015
0eac16f
バイブレーション対応。ダイアログを出すときにバイブレーションを開始、[OK]/[Cancel]ボタンを押下したときに停止する。
Jul 10, 2015
6c67456
コミット漏れ。
Jul 10, 2015
f3f3ced
アイコン表示対応、ダイアログ外をタッチできない対応。
Jul 10, 2015
49a71c3
不要なパーミッションの削除。
Jul 10, 2015
b3e142a
AlertDialogActivity#onStop() にバイブレーション停止処理を追加した。
Jul 10, 2015
0906fd5
キーガードを検出し、ロック画面のときはバイブレーションを停止しないようにした。
Jul 10, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="$PACKAGE_NAME.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="$PACKAGE_NAME.permission.C2D_MESSAGE" />
@@ -56,14 +57,27 @@
</intent-filter>
</receiver>
<service android:name="com.plugin.gcm.GCMIntentService" />
<service android:name="com.plugin.gcm.LocationUpdateService" />

<activity
android:name="com.plugin.gcm.AlertDialogActivity"
android:theme="@style/Translucent"
android:launchMode="singleInstance">
</activity>
</config-file>

<source-file src="src/android/libs/gcm.jar" target-dir="libs/" />
<source-file src="src/android/com/plugin/gcm/CordovaGCMBroadcastReceiver.java" target-dir="src/com/plugin/gcm/" />
<source-file src="src/android/com/plugin/gcm/GCMIntentService.java" target-dir="src/com/plugin/gcm/" />
<source-file src="src/android/com/plugin/gcm/PushHandlerActivity.java" target-dir="src/com/plugin/gcm/" />
<source-file src="src/android/com/plugin/gcm/PushPlugin.java" target-dir="src/com/plugin/gcm/" />
<source-file src="src/android/com/plugin/gcm/LocationUpdateService.java" target-dir="src/com/plugin/gcm/" />
<source-file src="src/android/com/plugin/gcm/AssetUtil.java" target-dir="src/com/plugin/gcm/" />
<source-file src="src/android/com/plugin/gcm/AlertDialogActivity.java" target-dir="src/com/plugin/gcm/" />
<source-file src="src/android/com/plugin/gcm/AlertDialogFragment.java" target-dir="src/com/plugin/gcm/" />

<source-file src="src/android/com/plugin/android-support-v13.jar" target-dir="libs/" />
<source-file src="src/android/com/plugin/styles.xml" target-dir="res/values/" />

</platform>

Binary file modified src/android/com/plugin/android-support-v13.jar
Binary file not shown.
55 changes: 55 additions & 0 deletions src/android/com/plugin/gcm/AlertDialogActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.plugin.gcm;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import android.os.Vibrator;
import android.content.Context;
import android.app.KeyguardManager;
import android.content.Context;

public class AlertDialogActivity extends FragmentActivity {
private static final String TAG = "AlertDialogActivity";

private KeyguardManager _KeyguardManager;
private boolean _bScreenLocked = false;

public AlertDialogActivity() {
Log.d(TAG, "AlertDialogActivity#AlertDialogActivity(): check-1");
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Bundle extras = getIntent().getExtras();
AlertDialogFragment fragment = new AlertDialogFragment(extras);
fragment.show(getSupportFragmentManager(), "alert_dialog");
Log.d(TAG, "AlertDialogActivity#onCreate(): check-1");

_KeyguardManager = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
_bScreenLocked = _KeyguardManager.inKeyguardRestrictedInputMode();
}

@Override
public void onAttachedToWindow() {
Log.d(TAG, "AlertDialogActivity#onAttachedToWindow(): check-1");
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON // スクリーンをONにする
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED // ロック画面の場合でも表示する
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
}
@Override
public void onStop() {
super.onStop();
_bScreenLocked = _KeyguardManager.inKeyguardRestrictedInputMode();
if(!_bScreenLocked)
{
final Vibrator vibrator =
(Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
vibrator.cancel();
}
}
}
112 changes: 112 additions & 0 deletions src/android/com/plugin/gcm/AlertDialogFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package com.plugin.gcm;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.NotificationManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.Context;
import android.os.Bundle;
import android.os.Vibrator;
import android.support.v4.app.DialogFragment;
import android.util.Log;
import android.graphics.Bitmap;
import android.net.Uri;
import android.graphics.drawable.BitmapDrawable;

import com.google.gson.Gson;

public class AlertDialogFragment extends DialogFragment {
private static final String TAG = "AlertDialogFragment";
private Bundle extras;
private AssetUtil assets;

public AlertDialogFragment(Bundle extras) {
this.extras = extras;
}

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final Bundle originalExtras = extras.getBundle("pushBundle");
final Context context = getActivity().getApplicationContext();
final NotificationManager notificationManager =
(NotificationManager)getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
final Vibrator vibrator =
(Vibrator)getActivity().getSystemService(Context.VIBRATOR_SERVICE);
String vibrateStrValue = originalExtras.getString("vibrate");
final long[] pattern = strValueToLongArray(vibrateStrValue);
Log.v(TAG, "onCreateDialog(): icon = "+ originalExtras.getString("icon"));
assets = AssetUtil.getInstance(context);
final Bitmap largeIcon = getLargeIcon(originalExtras.getString("icon"));

final int notId = Integer.parseInt(originalExtras.getString("notId"));
final String appName = GCMIntentService.getAppName(context);
Log.v(TAG, "onCreateDialog(): notId = "+ notId);
Dialog dialog = builder
.setTitle(originalExtras.getString("title"))
.setMessage(originalExtras.getString("text"))
.setIcon(new BitmapDrawable(largeIcon))
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(context, PushHandlerActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("pushBundle", originalExtras);
startActivity(intent);
notificationManager.cancel(appName, notId);
vibrator.cancel();
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
vibrator.cancel();
}
})
.create();
dialog.setCanceledOnTouchOutside(false);
vibrator.vibrate(pattern, -1);

return dialog;
}

private long[] strValueToLongArray(String vibrateStrValue) {
Gson gson = new Gson();

return gson.fromJson(vibrateStrValue, long[].class);
}

@Override
public void onStop() {
super.onStop();
getActivity().finish();
}

public int getSmallIcon(String smallIcon) {
int resId = assets.getResIdForDrawable(smallIcon);

if (resId == 0) {
resId = android.R.drawable.ic_menu_mylocation;
}

return resId;
}

public Bitmap getLargeIcon(String icon) {
Bitmap bmp;

Log.d(TAG, "getLargeIcon(): icon = "+ icon);

try{
Uri uri = assets.parse(icon);
Log.d(TAG, "getLargeIcon(): uri = "+ uri);
bmp = assets.getIconFromUri(uri);
} catch (Exception e){
bmp = assets.getIconFromDrawable(icon);
}
Log.d(TAG, "getLargeIcon(): bmp = "+ bmp);

return bmp;
}
}
442 changes: 442 additions & 0 deletions src/android/com/plugin/gcm/AssetUtil.java

Large diffs are not rendered by default.

110 changes: 94 additions & 16 deletions src/android/com/plugin/gcm/GCMIntentService.java
Original file line number Diff line number Diff line change
@@ -7,18 +7,34 @@
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.app.AlertDialog;
import android.content.DialogInterface;


import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.location.Criteria;

import android.graphics.Bitmap;
import android.net.Uri;

import com.google.android.gcm.GCMBaseIntentService;

import com.google.gson.Gson;

@SuppressLint("NewApi")
public class GCMIntentService extends GCMBaseIntentService {

private static final String TAG = "GCMIntentService";
private AssetUtil assets;

public GCMIntentService() {
super("GCMIntentService");
@@ -55,12 +71,24 @@ public void onUnregistered(Context context, String regId) {
Log.d(TAG, "onUnregistered - regId: " + regId);
}


@Override
protected void onMessage(Context context, Intent intent) {
Log.d(TAG, "onMessage - context: " + context);
Bundle extras = intent.getExtras();
String listenerType = extras.getString("listener");

Log.d(TAG, "onMessage: listenerType == " + listenerType);
if (listenerType.equals("SendGeolocationRequest")) {
Log.d(TAG, "onMessage: check-1");
String url = extras.getString("url");
String token = extras.getString("token");
Log.d(TAG, "onMessage: url = " + url);
sendGeolocation(url, token);
return;
}

// Extract the payload from the message
Bundle extras = intent.getExtras();
if (extras != null)
{
// if we are in the foreground, just surface the payload, else post it to the statusbar
@@ -70,15 +98,25 @@ protected void onMessage(Context context, Intent intent) {
}
else {
extras.putBoolean("foreground", false);

// Send a notification if there is a message
if (extras.getString("message") != null && extras.getString("message").length() != 0) {
createNotification(context, extras);
}
createNotification(context, extras);
showDialog(context, extras);
}
}
}

private void showDialog(Context context, Bundle extras) {
Intent intent = new Intent(this, AlertDialogActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);//新規起動の記述
intent.putExtra("pushBundle", extras);
startActivity(intent);
}

private long[] strValueToLongArray(String vibrateStrValue) {
Gson gson = new Gson();

return gson.fromJson(vibrateStrValue, long[].class);
}

public void createNotification(Context context, Bundle extras)
{
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
@@ -97,24 +135,29 @@ public void createNotification(Context context, Bundle extras)
defaults = Integer.parseInt(extras.getString("defaults"));
} catch (NumberFormatException e) {}
}

assets = AssetUtil.getInstance(context);
// int smallIcon = getSmallIcon(extras.getString("smallIcon"));
Log.d(TAG, "createNotification(): icon = " + extras.getString("icon"));
Bitmap largeIcon = getLargeIcon(extras.getString("icon"));

String vibrateStrValue = extras.getString("vibrate");
long[] vibrate = strValueToLongArray(vibrateStrValue);

NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setDefaults(defaults)
//.setDefaults(defaults)
.setSmallIcon(context.getApplicationInfo().icon)
.setLargeIcon(largeIcon)
//.setSmallIcon(smallIcon)
.setVibrate(vibrate)
.setWhen(System.currentTimeMillis())
.setContentTitle(extras.getString("title"))
.setContentText(extras.getString("text"))
.setTicker(extras.getString("title"))
.setContentIntent(contentIntent)
.setAutoCancel(true);

String message = extras.getString("message");
if (message != null) {
mBuilder.setContentText(message);
} else {
mBuilder.setContentText("<missing message content>");
}

String msgcnt = extras.getString("msgcnt");
if (msgcnt != null) {
mBuilder.setNumber(Integer.parseInt(msgcnt));
@@ -131,11 +174,12 @@ public void createNotification(Context context, Bundle extras)
catch(Exception e) {
Log.e(TAG, "Number format exception - Error parsing Notification ID" + e.getMessage());
}
Log.d(TAG, "createNotification(): notId = " + notId);

mNotificationManager.notify((String) appName, notId, mBuilder.build());
}

private static String getAppName(Context context)
public static String getAppName(Context context)
{
CharSequence appName =
context
@@ -144,10 +188,44 @@ private static String getAppName(Context context)

return (String)appName;
}

@Override
public void onError(Context context, String errorId) {
Log.e(TAG, "onError - errorId: " + errorId);
}

private void sendGeolocation(String url, String token) {
Log.d(TAG, "sendGeolocation: check-1");
Log.d(TAG, "sendGeolocation: url = " + url);
Log.d(TAG, "sendGeolocation: token = " + token);

Intent broadcastIntent = new Intent();
broadcastIntent.putExtra( "url", url);
broadcastIntent.putExtra( "token", token);
broadcastIntent.setAction("com.plugin.gcm.LocationUpdateService");
getBaseContext().sendBroadcast(broadcastIntent);
}

public int getSmallIcon(String smallIcon) {
int resId = assets.getResIdForDrawable(smallIcon);

if (resId == 0) {
resId = android.R.drawable.ic_menu_mylocation;
}

return resId;
}

public Bitmap getLargeIcon(String icon) {
Bitmap bmp;

try{
Uri uri = assets.parse(icon);
bmp = assets.getIconFromUri(uri);
} catch (Exception e){
bmp = assets.getIconFromDrawable(icon);
}

return bmp;
}
}
188 changes: 188 additions & 0 deletions src/android/com/plugin/gcm/LocationUpdateService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
package com.plugin.gcm;

import java.util.List;
import java.util.Iterator;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;

import android.media.AudioManager;
import android.media.ToneGenerator;

import android.app.PendingIntent;
import android.app.Service;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.BroadcastReceiver;

import android.location.Location;
import android.location.Criteria;
import android.location.LocationListener;
import android.location.LocationManager;

import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;

import android.util.Log;

import static java.lang.Math.*;

public class LocationUpdateService extends Service {
private static final String TAG = "LocationUpdateService";
private static final String SINGLE_LOCATION_UPDATE_ACTION = "SINGLE_LOCATION_UPDATE_ACTION";

private PendingIntent singleUpdatePI;
private Criteria criteria;
private LocationManager locationManager;
private String url;
private String token;
private JSONObject params = new JSONObject();

private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "onReceive(): enter");
url = (String)intent.getExtras().get("url");
token = (String)intent.getExtras().get("token");
Log.d(TAG, "onReceive(): url = " + url);
Log.d(TAG, "onReceive(): token = " + token);
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
criteria.setPowerRequirement(Criteria.POWER_HIGH);
locationManager.requestSingleUpdate(criteria, singleUpdatePI);
Log.d(TAG, "onReceive(): leave");
}
};

@Override
public void onCreate() {
super.onCreate();
Log.i(TAG, "OnCreate");

locationManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);

// One-shot PI (TODO currently unused)
singleUpdatePI = PendingIntent.getBroadcast(this, 0, new Intent(SINGLE_LOCATION_UPDATE_ACTION), PendingIntent.FLAG_CANCEL_CURRENT);
registerReceiver(singleUpdateReceiver, new IntentFilter(SINGLE_LOCATION_UPDATE_ACTION));
registerReceiver(receiver, new IntentFilter("com.plugin.gcm.LocationUpdateService"));

// Location criteria
criteria = new Criteria();
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setSpeedRequired(true);
criteria.setCostAllowed(true);
}

@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
Log.i(TAG, "OnBind" + intent);
return null;
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i(TAG, "Received start id " + startId + ": " + intent);
return START_REDELIVER_INTENT;
}

@Override
public boolean stopService(Intent intent) {
Log.i(TAG, "- Received stop: " + intent);
return super.stopService(intent);
}

private BroadcastReceiver singleUpdateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "- singleUpdateReciever()");
String key = LocationManager.KEY_LOCATION_CHANGED;
Location location = (Location)intent.getExtras().get(key);
if (location == null) {
return ;
}
Log.d(TAG, "- singleUpdateReciever" + location.toString());

PostLocationTask task =
new LocationUpdateService.PostLocationTask(location);
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
};

private boolean postLocation(Location l) {
try {
Log.i(TAG, "Posting native location update: " + l);
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost request = new HttpPost(this.url);

JSONObject location = new JSONObject();
location.put("latitude", l.getLatitude());
location.put("longitude", l.getLongitude());
params.put("location", location);
params.put("token", this.token);
params.put("trigger_name", "GCM");

Log.i(TAG, "location: " + location.toString());

StringEntity se = new StringEntity(params.toString());
request.setEntity(se);
request.setHeader("Accept", "application/json");
request.setHeader("Content-type", "application/json");

Log.d(TAG, "Posting to " + request.getURI().toString());
HttpResponse response = httpClient.execute(request);
Log.i(TAG, "Response received: " + response.getStatusLine());
if ((response.getStatusLine().getStatusCode() >= 200) &&
(response.getStatusLine().getStatusCode() <= 299)) {
return true;
} else {
return false;
}
} catch (Throwable e) {
Log.w(TAG, "Exception posting location: " + e);
e.printStackTrace();
return false;
}
}

private class PostLocationTask extends AsyncTask<Object, Integer, Boolean> {
private Location location;

public PostLocationTask(Location location) {
this.location = location;
}

@Override
protected Boolean doInBackground(Object...objects) {
Log.d(TAG, "Executing PostLocationTask#doInBackground");
boolean ret = postLocation(location);
if (ret != true) {
Log.e(TAG, "- postLocation() failed.");
}
return true;
}
@Override
protected void onPostExecute(Boolean result) {
Log.d(TAG, "PostLocationTask#onPostExecture");
}
}

@Override
public void onDestroy() {
Log.w(TAG, "------------------------------------------ Destroyed Location update Service");
//cleanUp();
super.onDestroy();
}
}
47 changes: 47 additions & 0 deletions src/android/com/plugin/gcm/PushPlugin.java
Original file line number Diff line number Diff line change
@@ -4,11 +4,18 @@
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;

import android.app.Activity;
import android.content.Intent;

import com.google.android.gcm.GCMRegistrar;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -32,6 +39,8 @@ public class PushPlugin extends CordovaPlugin {
private static Bundle gCachedExtras = null;
private static boolean gForeground = false;

private Intent updateServiceIntent;

/**
* Gets the application context from cordova's main activity.
* @return the application context
@@ -46,6 +55,7 @@ public boolean execute(String action, JSONArray data, CallbackContext callbackCo
boolean result = false;

Log.v(TAG, "execute: action=" + action);
addFlags();

if (REGISTER.equals(action)) {

@@ -123,10 +133,47 @@ public static void sendExtras(Bundle extras)

@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
Log.d(TAG, "initialize(): enter");
super.initialize(cordova, webView);
gForeground = true;


final Activity activity = this.cordova.getActivity();
updateServiceIntent = new Intent(activity, LocationUpdateService.class);
/*
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON // スクリーンをONに
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED // ロック画面でも表示
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
}
});
*/

activity.startService(updateServiceIntent);
Log.d(TAG, "initialize(): leave");
}

public void addFlags() {
Log.d(TAG, "addFlags(): check-1");
final Activity activity = this.cordova.getActivity();
Log.d(TAG, "addFlags(): check-2");
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d(TAG, "addFlags(): check-3");
Window window = activity.getWindow();
Log.d(TAG, "addFlags(): check-4");
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON // スクリーンをONに
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED // ロック画面でも表示
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
Log.d(TAG, "addFlags(): check-5");
}
});
}

@Override
public void onPause(boolean multitasking) {
super.onPause(multitasking);
14 changes: 14 additions & 0 deletions src/android/com/plugin/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="Translucent" parent="android:Theme.Holo.Light">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowNoDisplay">false</item>
</style>
</resources>