Skip to content

Commit a57b5d4

Browse files
committed
Updating target sdk to 34, with exported activities and exported flag for register receivers
1 parent df2ed4a commit a57b5d4

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

gpslogger/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ android {
4343
applicationId "com.mendhak.gpslogger"
4444
minSdkVersion 21
4545

46-
targetSdkVersion 33
46+
targetSdkVersion 34
4747
compileSdk 34
4848
versionCode 132
4949
versionName "132-rc1"

gpslogger/src/main/AndroidManifest.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@
9595
<activity
9696
android:name=".MainPreferenceActivity"
9797
android:label="@string/settings_screen_name"
98-
android:parentActivityName=".GpsMainActivity" >
98+
android:parentActivityName=".GpsMainActivity"
99+
android:exported="true"
100+
>
99101
<meta-data
100102
android:name="android.support.PARENT_ACTIVITY"
101103
android:value="com.mendhak.gpslogger.GpsMainActivity" />
@@ -106,7 +108,9 @@
106108
android:name=".Faqtivity"
107109
android:label="@string/faq_screen_title"
108110
android:launchMode="singleTask"
109-
android:parentActivityName=".GpsMainActivity" >
111+
android:parentActivityName=".GpsMainActivity"
112+
android:exported="true"
113+
>
110114
<meta-data
111115
android:name="android.support.PARENT_ACTIVITY"
112116
android:value="com.mendhak.gpslogger.GpsMainActivity" />

gpslogger/src/main/java/com/mendhak/gpslogger/common/Systems.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,16 @@ public static String getAndroidId() {
8484
}
8585

8686
public static BatteryInfo getBatteryInfo(Context context){
87-
Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
87+
Intent batteryIntent = null;
88+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
89+
batteryIntent = ContextCompat.registerReceiver(context, null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED),
90+
ContextCompat.RECEIVER_EXPORTED);
91+
}
92+
else {
93+
batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
94+
}
95+
96+
8897
int level = batteryIntent != null ? batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) : 0;
8998
int scale = batteryIntent != null ? batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1) : 0;
9099

0 commit comments

Comments
 (0)