diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..b268ef3 --- /dev/null +++ b/.idea/deploymentTargetSelector.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 169fd0d..0897082 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -1,18 +1,18 @@ + diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..7e340a7 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 37a7509..bd7b6ec 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,5 @@ - - + diff --git a/.idea/other.xml b/.idea/other.xml new file mode 100644 index 0000000..0d3a1fb --- /dev/null +++ b/.idea/other.xml @@ -0,0 +1,263 @@ + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 167af30..3c794f0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,11 +5,11 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 28 + compileSdkVersion 30 defaultConfig { applicationId "com.example.myapplication" minSdkVersion 15 - targetSdkVersion 28 + targetSdkVersion 30 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ac31715..b273c45 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,16 +9,17 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - - - - - - + + + + + + + + + + + super.onOptionsItemSelected(item) } } - - + override fun onStop() { + super.onStop() + unregisterReceiver(mCallbackStatusReceiver) + } + // mCallbackStatusReceiver: Listens to broadcast from Mason Platform Broadcast Notifications + private val mCallbackStatusReceiver: BroadcastReceiver = object : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + // This method is called when the BroadcastReceiver is receiving an Intent broadcast. + if (intent.action.equals(ACTION_PUSH_RECEIVE)) { + val command = intent.getStringExtra(EXTRA_PUSH_COMMAND) + var args = intent.getStringArrayExtra(EXTRA_PUSH_ARGUMENTS) + args = args ?: arrayOf() + // Handle your push logic here + Log.i(TAG, String.format("Got a PUSH message, command(%s), %d args ", command, args.size)) + Toast.makeText(context.applicationContext,command, Toast.LENGTH_LONG).show() + } + } + } } diff --git a/app/src/main/java/com/example/myapplication/MyReceiver.kt b/app/src/main/java/com/example/myapplication/MyReceiver.kt index 41df820..0f6f80c 100644 --- a/app/src/main/java/com/example/myapplication/MyReceiver.kt +++ b/app/src/main/java/com/example/myapplication/MyReceiver.kt @@ -7,24 +7,21 @@ import android.util.Log import android.widget.Toast -class MyReceiver : BroadcastReceiver() { - val ACTION_PUSH_RECEIVE = "com.bymason.platform.core.action.PUSH_RECEIVE" - val EXTRA_PUSH_COMMAND = "com.bymason.platform.core.extra.PUSH_COMMAND" - val EXTRA_PUSH_ARGUMENTS = "com.bymason.platform.core.extra.PUSH_ARGS" - val TAG = "MYAPP" - - override fun onReceive(context: Context, intent: Intent) { - // This method is called when the BroadcastReceiver is receiving an Intent broadcast. - if (intent.action.equals(ACTION_PUSH_RECEIVE)) { - val command = intent.getStringExtra(EXTRA_PUSH_COMMAND) - var args = intent.getStringArrayExtra(EXTRA_PUSH_ARGUMENTS) - args = args ?: arrayOf() - // Handle your push logic here - Log.i( - TAG, - String.format("Got a PUSH message, command(%s), %d args ", command, args.size) - ) - Toast.makeText(context.applicationContext,command,Toast.LENGTH_LONG).show() - } - } -} +//class MyReceiver : BroadcastReceiver() { +// val ACTION_PUSH_RECEIVE = "com.bymason.platform.core.action.PUSH_RECEIVE" +// val EXTRA_PUSH_COMMAND = "com.bymason.platform.core.extra.PUSH_COMMAND" +// val EXTRA_PUSH_ARGUMENTS = "com.bymason.platform.core.extra.PUSH_ARGS" +// val TAG = "MYAPP" +// +// override fun onReceive(context: Context, intent: Intent) { +// // This method is called when the BroadcastReceiver is receiving an Intent broadcast. +// if (intent.action.equals(ACTION_PUSH_RECEIVE)) { +// val command = intent.getStringExtra(EXTRA_PUSH_COMMAND) +// var args = intent.getStringArrayExtra(EXTRA_PUSH_ARGUMENTS) +// args = args ?: arrayOf() +// // Handle your push logic here +// Log.i(TAG, String.format("Got a PUSH message, command(%s), %d args ", command, args.size)) +// Toast.makeText(context.applicationContext,command,Toast.LENGTH_LONG).show() +// } +// } +//}