Fixed notification for android 8 and higher
This commit is contained in:
parent
6fe2925483
commit
6a0285dfa7
Binary file not shown.
|
@ -1,29 +0,0 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<Objective-C-extensions>
|
||||
<file>
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
|
||||
</file>
|
||||
<class>
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
|
||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
|
||||
</class>
|
||||
<extensions>
|
||||
<pair source="cpp" header="h" fileNamingConvention="NONE" />
|
||||
<pair source="c" header="h" fileNamingConvention="NONE" />
|
||||
</extensions>
|
||||
</Objective-C-extensions>
|
||||
</code_scheme>
|
||||
</component>
|
|
@ -6,8 +6,8 @@ android {
|
|||
applicationId "org.disroot.disrootapp"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 28
|
||||
versionCode 17
|
||||
versionName "1.1.4"
|
||||
versionCode 18
|
||||
versionName "1.1.5"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.annotation.SuppressLint;
|
|||
import android.annotation.TargetApi;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DownloadManager;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.ProgressDialog;
|
||||
|
@ -1945,6 +1946,8 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
|
|||
|
||||
//Notification
|
||||
private void sendNotification() throws JSONException {
|
||||
String CHANNEL_ID = "316865431";
|
||||
String CHANNEL_NAME = "StateNotification";
|
||||
HttpHandler sh = new HttpHandler();
|
||||
String jsonStrincidents0 = sh.makeServiceCall(incidenturl0);
|
||||
JSONObject jsonObj = new JSONObject(jsonStrincidents0);
|
||||
|
@ -1960,8 +1963,22 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
|
|||
|
||||
Intent goState = new Intent(MainActivity.this, StateMessagesActivity.class);
|
||||
PendingIntent launchStateMessages = PendingIntent.getActivity(MainActivity.this,0, goState, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
NotificationCompat.Builder mBuilder =
|
||||
new NotificationCompat.Builder(this)
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
|
||||
|
||||
inboxStyle.addLine(message);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// I would suggest that you use IMPORTANCE_DEFAULT instead of IMPORTANCE_HIGH
|
||||
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
|
||||
channel.enableVibration(true);
|
||||
channel.setLightColor(Color.MAGENTA);
|
||||
channel.enableLights(true);
|
||||
channel.setVibrationPattern(new long[]{50,500,100,300,50,300});
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID)
|
||||
.setAutoCancel( true )
|
||||
.setOngoing(true)
|
||||
.setSmallIcon(R.drawable.ic_state)
|
||||
|
@ -1970,12 +1987,16 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
|
|||
.setContentInfo(message)//get text message from json :-)
|
||||
.setContentIntent(launchStateMessages);
|
||||
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
||||
mBuilder.setSound(alarmSound)
|
||||
notificationBuilder.setSound(alarmSound)
|
||||
.setVibrate(new long[]{50,500,100,300,50,300})
|
||||
.setLights(Color.MAGENTA, 3000, 3000);
|
||||
NotificationManager mNotificationManager =
|
||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.notify(001, mBuilder.build());
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
|
||||
notificationBuilder.setChannelId(CHANNEL_ID);
|
||||
}
|
||||
|
||||
notificationManager.notify(CHANNEL_ID, 1, notificationBuilder.build());
|
||||
}
|
||||
|
||||
//show snackbar to avoid exit on backpress
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<changelog>
|
||||
<release version="1.1.5" versioncode="18" >
|
||||
<change>Notifications works on Android 8 and higher now</change>
|
||||
<change>Updated Serbian translation</change>
|
||||
</release>
|
||||
<release version="1.1.4" versioncode="17" >
|
||||
<change>Fixed App closing when pressing go back</change>
|
||||
<change>Edited state error message</change>
|
||||
|
|
Loading…
Reference in New Issue