Skip to content

Commit

Permalink
Update deprecated field
Browse files Browse the repository at this point in the history
  • Loading branch information
jahirfiquitiva committed Jul 25, 2018
1 parent 420bc35 commit 4c89256
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package jahirfiquitiva.libs.blueprint.helpers.extensions

import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
Expand Down Expand Up @@ -47,6 +48,7 @@ private class EmailBuilder(val email: String, val subject: String) {

data class Package(val packageName: String, val appName: String)

@SuppressLint("NewApi")
fun getIntent(context: Context): Intent {
val intent = Intent(Intent.ACTION_SEND)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
Expand Down Expand Up @@ -77,9 +79,15 @@ private class EmailBuilder(val email: String, val subject: String) {
if (appInfo) {
try {
val appInfo = context.packageManager.getPackageInfo(context.packageName, 0)

@Suppress("DEPRECATION")
val versionCode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
appInfo.longVersionCode.toString()
} else appInfo.versionCode.toString()

emailBuilder.append("\nApp: ").append(context.packageName)
.append("\nApp Version Name: ").append(appInfo.versionName)
.append("\nApp Version Code: ").append(appInfo.versionCode).append("\n")
.append("\nApp Version Code: ").append(versionCode).append("\n")
} catch (e: PackageManager.NameNotFoundException) {
BL.e("EmailBuilder packageInfo not found")
}
Expand Down

0 comments on commit 4c89256

Please sign in to comment.