Commit b7f32853 by baijinqiu

fix

parent dec8ab5b
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="2e775c3f-ff13-4f54-ba20-3e0eeadc9822" name="Default Changelist" comment=""> <list default="true" id="2e775c3f-ff13-4f54-ba20-3e0eeadc9822" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/plugin.xml" beforeDir="false" afterPath="$PROJECT_DIR$/plugin.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/android/ONService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/android/ONService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/android/onservice/NotificationService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/android/onservice/NotificationService.java" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
...@@ -49,6 +52,9 @@ ...@@ -49,6 +52,9 @@
<updated>1589203043741</updated> <updated>1589203043741</updated>
<workItem from="1589203044907" duration="4164000" /> <workItem from="1589203044907" duration="4164000" />
<workItem from="1589246330563" duration="5727000" /> <workItem from="1589246330563" duration="5727000" />
<workItem from="1589419123592" duration="528000" />
<workItem from="1589530335696" duration="615000" />
<workItem from="1589766857083" duration="2925000" />
</task> </task>
<servers /> <servers />
</component> </component>
...@@ -60,7 +66,9 @@ ...@@ -60,7 +66,9 @@
<map> <map>
<entry key="MAIN"> <entry key="MAIN">
<value> <value>
<State /> <State>
<option name="COLUMN_ORDER" />
</State>
</value> </value>
</entry> </entry>
</map> </map>
......
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-ONService" version="1.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" <plugin id="cordova-plugin-ONService" version="1.0.0"
xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
<name>ONService</name> <name>ONService</name>
<js-module name="ONService" src="www/ONService.js"> <js-module name="ONService" src="www/ONService.js">
...@@ -9,6 +10,7 @@ ...@@ -9,6 +10,7 @@
<config-file parent="/*" target="res/xml/config.xml"> <config-file parent="/*" target="res/xml/config.xml">
<feature name="ONService"> <feature name="ONService">
<param name="android-package" value="com.orhon.notification.ONService"/> <param name="android-package" value="com.orhon.notification.ONService"/>
<param name="onload" value="true"/>
</feature> </feature>
</config-file> </config-file>
<config-file parent="/*" target="AndroidManifest.xml"> <config-file parent="/*" target="AndroidManifest.xml">
...@@ -17,20 +19,21 @@ ...@@ -17,20 +19,21 @@
</config-file> </config-file>
<config-file parent="/manifest/application" target="AndroidManifest.xml"> <config-file parent="/manifest/application" target="AndroidManifest.xml">
<service <service android:name="com.orhon.notification.onservice.NotificationService" android:enabled="true" android:exported="true">
android:name="com.orhon.notification.onservice.NotificationService" <intent-filter android:priority="1000">
android:enabled="true"
android:exported="true">
<intent-filter android:priority="1000" >
<action android:name="notificationTest"/> <action android:name="notificationTest"/>
</intent-filter> </intent-filter>
</service> </service>
</config-file> </config-file>
<source-file src="src/android/ONService.java" target-dir="src/com/orhon/notification/"/> <source-file src="src/android/ONService.java" target-dir="src/com/orhon/notification/"/>
<source-file src="src/android/onservice/NotificationService.java" <source-file src="src/android/onservice/NotificationService.java" target-dir="src/com/orhon/notification/onservice"/>
target-dir="src/com/orhon/notification/onservice"/> <source-file src="src/android/onservice/HandleService.java" target-dir="src/com/orhon/notification/onservice"/>
<framework src="com.android.support:support-annotations:27.+"></framework>
<framework src="com.squareup.okhttp3:okhttp:4.6.0"></framework>
<framework src="com.squareup.okhttp3:mockwebserver:4.6.0"></framework>
<framework src="com.google.code.gson:gson:2.8.6"></framework>
</platform> </platform>
</plugin> </plugin>
package com.orhon.notification; package com.orhon.notification;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service; import android.app.Service;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
//import android.support.annotation.RequiresApi;
import android.util.Log; import android.util.Log;
import com.orhon.notification.onservice.NotificationService; import com.orhon.notification.onservice.NotificationService;
import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext; import org.apache.cordova.CallbackContext;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
// import io.cordova.hellocordova.R;
import static android.content.Context.NOTIFICATION_SERVICE;
/** /**
* This class echoes a string called from JavaScript. * This class echoes a string called from JavaScript.
*/ */
...@@ -37,9 +23,10 @@ public class ONService extends CordovaPlugin { ...@@ -37,9 +23,10 @@ public class ONService extends CordovaPlugin {
private ServiceConnection connection = new ServiceConnection() { private ServiceConnection connection = new ServiceConnection() {
@Override @Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) { public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
myBinder = (NotificationService.MyBinder) iBinder;
NotificationService.webView = webView; NotificationService.webView = webView;
NotificationService.cordovaPlugin = cordova; NotificationService.cordovaPlugin = cordova;
myBinder = (NotificationService.MyBinder) iBinder;
} }
@Override @Override
...@@ -72,6 +59,7 @@ public class ONService extends CordovaPlugin { ...@@ -72,6 +59,7 @@ public class ONService extends CordovaPlugin {
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
// webView.loadUrl("http://localhost/tabs/tab3");
cordova.getActivity().startService(intent); cordova.getActivity().startService(intent);
cordova.getActivity().bindService( cordova.getActivity().bindService(
intent, intent,
......
package com.orhon.notification.onservice;
import android.app.IntentService;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.util.Log;
import io.ionic.starter.MainActivity;
public class HandleService extends IntentService {
private static final String TAG = "HandleService";
public HandleService() {
super("");
}
public HandleService(String name) {
super(name);
}
@Override
protected void onHandleIntent(@Nullable Intent intent) {
Log.e(TAG, "onHandleIntent: id " + intent.getStringExtra("id"));
Log.e(TAG, "onHandleIntent: url "+ intent.getStringExtra("url"));
NotificationService.webView.loadUrl(intent.getStringExtra("url"));
}
@Override
public int onStartCommand(@Nullable Intent intent, int flags, int startId) {
NotificationService.cordovaPlugin.getActivity().startActivity(new Intent(NotificationService.cordovaPlugin.getContext(), MainActivity.class));
Log.e(TAG, "onStartCommand: id " + intent.getStringExtra("id"));
Log.e(TAG, "onStartCommand: url "+ intent.getStringExtra("url"));
return super.onStartCommand(intent,flags,startId);
}
@Override
public void onDestroy() {
super.onDestroy();
Log.e(TAG, "onDestroy: ");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment