|
@@ -7,10 +7,14 @@ import android.content.Intent
|
|
|
import android.content.IntentFilter
|
|
|
import android.net.Uri
|
|
|
import android.os.Build
|
|
|
+import android.os.Bundle
|
|
|
import android.os.Environment
|
|
|
+import android.os.Handler
|
|
|
+import android.util.Log
|
|
|
import android.widget.Toast
|
|
|
import androidx.core.content.FileProvider
|
|
|
import com.khmer9.sbcmain.R
|
|
|
+import okhttp3.internal.wait
|
|
|
import java.io.File
|
|
|
|
|
|
|
|
@@ -65,30 +69,58 @@ class DownloadController(private val context: Context, private val url: String,
|
|
|
install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
|
|
install.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
|
install.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true)
|
|
|
+ install.putExtra(Intent.EXTRA_RETURN_RESULT, true)
|
|
|
install.data = contentUri
|
|
|
- install.putExtra("token", token)
|
|
|
Toast.makeText(context, "ដោនឡូតបានជោគជ័យ", Toast.LENGTH_LONG).show()
|
|
|
- context.startActivity(install)
|
|
|
+
|
|
|
+ val bundle = Bundle()
|
|
|
+ bundle.putString("token", token)
|
|
|
+ install.putExtra("token", bundle)
|
|
|
+
|
|
|
context.unregisterReceiver(this)
|
|
|
(context as ShareActivity).apply {
|
|
|
- finish()
|
|
|
+ startActivity(install)
|
|
|
+
|
|
|
+ Handler().postDelayed({
|
|
|
+ val launchIntent = packageManager.getLaunchIntentForPackage("com.sambath.apong")
|
|
|
+ if (launchIntent != null) {
|
|
|
+ launchIntent?.putExtra("token", token)
|
|
|
+ Log.d("XXX>>>", "luanch activity")
|
|
|
+ startActivity(launchIntent)
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ //finish()
|
|
|
}
|
|
|
- // finish()
|
|
|
} else {
|
|
|
val install = Intent(Intent.ACTION_VIEW)
|
|
|
+ install.putExtra(Intent.EXTRA_RETURN_RESULT, true)
|
|
|
install.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
|
|
install.setDataAndType(
|
|
|
uri,
|
|
|
APP_INSTALL_PATH
|
|
|
)
|
|
|
- install.putExtra("token", token)
|
|
|
+
|
|
|
Toast.makeText(context, "ដោនឡូតបានជោគជ័យ", Toast.LENGTH_LONG).show()
|
|
|
- context.startActivity(install)
|
|
|
- context.unregisterReceiver(this)
|
|
|
+
|
|
|
+ val bundle = Bundle()
|
|
|
+ bundle.putString("token", token)
|
|
|
+ install.putExtra("token", bundle)
|
|
|
+
|
|
|
+ //context.unregisterReceiver(this)
|
|
|
(context as ShareActivity).apply {
|
|
|
- finish()
|
|
|
+ startActivity(install)
|
|
|
+
|
|
|
+ Handler().postDelayed({
|
|
|
+ val launchIntent = packageManager.getLaunchIntentForPackage("com.sambath.apong")
|
|
|
+ if (launchIntent != null) {
|
|
|
+ launchIntent?.putExtra("token", token)
|
|
|
+ startActivity(launchIntent)
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ }, 3000)
|
|
|
+ //finish()
|
|
|
}
|
|
|
- // finish()
|
|
|
}
|
|
|
}
|
|
|
}
|