Skip to content

Commit

Permalink
Updating target sdk to 34, with exported activities and exported flag…
Browse files Browse the repository at this point in the history
… for register receivers
  • Loading branch information
mendhak committed Oct 1, 2024
1 parent df2ed4a commit a57b5d4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gpslogger/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ android {
applicationId "com.mendhak.gpslogger"
minSdkVersion 21

targetSdkVersion 33
targetSdkVersion 34
compileSdk 34
versionCode 132
versionName "132-rc1"
Expand Down
8 changes: 6 additions & 2 deletions gpslogger/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@
<activity
android:name=".MainPreferenceActivity"
android:label="@string/settings_screen_name"
android:parentActivityName=".GpsMainActivity" >
android:parentActivityName=".GpsMainActivity"
android:exported="true"
>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mendhak.gpslogger.GpsMainActivity" />
Expand All @@ -106,7 +108,9 @@
android:name=".Faqtivity"
android:label="@string/faq_screen_title"
android:launchMode="singleTask"
android:parentActivityName=".GpsMainActivity" >
android:parentActivityName=".GpsMainActivity"
android:exported="true"
>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mendhak.gpslogger.GpsMainActivity" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,16 @@ public static String getAndroidId() {
}

public static BatteryInfo getBatteryInfo(Context context){
Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
Intent batteryIntent = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
batteryIntent = ContextCompat.registerReceiver(context, null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED),
ContextCompat.RECEIVER_EXPORTED);
}
else {
batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}


int level = batteryIntent != null ? batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) : 0;
int scale = batteryIntent != null ? batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1) : 0;

Expand Down

0 comments on commit a57b5d4

Please sign in to comment.