I have 2 app and i want app A share data with B by content provider, i can access content provider in app A but not in app B.I feel like my permission mess up but idk how to fixe it.
Heres my file...
App A's manifest file:
<permission android:name="myper.READ" android:protectionLevel="normal" />
<permission android:name="myper.WRITE" android:protectionLevel="normal" />
<application
android:name=".ui.MyApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Ex">
<activity android:name="com.abcd.aaaaa.ui.MainActivity"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:authorities="com.advance.usercontentprovider"
android:name=".contentprovider.UserContentProvider"
android:enabled="true"
android:exported="true"
android:multiprocess="true"
android:readPermission="myper.READ"
android:writePermission="myper.WRITE"
/>
</application>
and B's manifest file:
<uses-permission android:name="myper.READ" />
<uses-permission android:name="myper.WRITE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.aaaa">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Custom Content Provider:
val PROVIDER_NAME = "com.advance.usercontentprovider"
val URL = "content://$PROVIDER_NAME/users"
val CONTENT_URI = Uri.parse(URL)
override fun onCreate(): Boolean {
return true
}
val URI_ALL_ITEMS_CODE = 1
val URI_ONE_ITEM_CODE = 2
var uriMatcher: UriMatcher? = null
init
{
uriMatcher = UriMatcher(UriMatcher.NO_MATCH)
uriMatcher!!.addURI(PROVIDER_NAME, "users", URI_ALL_ITEMS_CODE)
uriMatcher!!.addURI(PROVIDER_NAME, "users" + "/#", URI_ONE_ITEM_CODE)
}
override fun query(
uri: Uri,
projection: Array<out String>?,
selection: String?,
selectionArgs: Array<out String>?,
sortOrder: String?
): Cursor? {
/// do smt
}
override fun getType(uri: Uri): String? {
// do smt
}
override fun insert(uri: Uri, values: ContentValues?): Uri? {
// do smt
}
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int {
// do smt
}
override fun update(
uri: Uri,
values: ContentValues?,
selection: String?,
selectionArgs: Array<out String>?
): Int {
// do smt
}
and every time i call this in app B
val cursor = contentResolver?.query(
Uri.parse("content://com.advance.usercontentprovider/users")
, null, null, null, null)
cursor always null.
Ive tried all the solutions that i found but nothing work.Help :"<
I realize that im using android 11 and they limit the package visibility so just need to add
<queries>
<provider
android:authorities="com.advance.usercontentprovider" />
</queries>
in app B's manifest (not in application tag) file so B can see your custom content provider of A
Related
I am making a app to read a text file from an external storage through Kotlin. Even after adding permission tags and changing options in the manifest file, the following error is displayed and the text file cannot be imported. How can I solve this?
errCode:
java.lang.IllegalArgumentException: File content://com.android.externalstorage.documents/document/primary%3ADocuments%2Ftest.txt contains a path separator
kotlin File
class MainActivity : AppCompatActivity() {
val getTextCode:Int = 2
override fun onCreate(savedInstanceState: Bundle?) {
val vBinding = ActivityMainBinding.inflate(layoutInflater)
super.onCreate(savedInstanceState)
setContentView(vBinding.root)
vBinding.getFromTxt.setOnClickListener {
val downUri = Uri.parse("/storage/self/primary/Documents")
openFile(downUri)
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == getTextCode && resultCode == Activity.RESULT_OK) {
try{
data?.data?.also { uri ->
Toast.makeText(this, uri.toString(), Toast.LENGTH_SHORT).show()
Log.d("test", uri.toString())
openFileInput(uri.toString()).bufferedReader().useLines{ lines->
Log.d("test", lines.toString())
}
}
}catch(err:Exception){
Log.d("test", err.toString())
}
}
}
private fun openFile(pickerInitialUri: Uri){
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
type = "text/*"
putExtra(DocumentsContract.EXTRA_INITIAL_URI, pickerInitialUri)
}
startActivityForResult(intent, getTextCode)
}
}
manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.questionbank">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.QuestionBank"
android:requestLegacyExternalStorage="true"
>
<activity
android:name=".EditActivity"
android:exported="false" />
<activity
android:name=".TestActivity"
android:exported="false" />
<activity
android:name=".PrintActivity"
android:exported="false" />
<activity
android:name=".InputActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
openFileInput(uri.toString()
The method openFileInput() only expects a file name. Not a file path or a complete content scheme. And it would search for a file with that name in getFilesDir().
If you want to read the file using the uri then open an inputstream for the uri and read from the stream. In Java:
InputStream is = getContentResolver().openInputStream(uri);
Further you do not need any permission to do so. Nor do you have to change options whatever you mean by that.
// READ_CALL_LOG permission works only once after first installation of the app. when I install it again from android studio the permission does not appear and the app does not read the call logs. This also happens after installing the app and closing it. after opening it again, the call logs disappeared. I also call this activity from another login activity
// My AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.calllog">
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.WRITE_CALL_LOG"/>
<application
android:allowBackup="true"
android:icon="#drawable/img"
android:label="#string/app_name"
android:roundIcon="#drawable/img"
android:supportsRtl="true"
android:theme="#style/Theme.CallLog"
android:usesCleartextTraffic="true">
<activity
android:name=".HomeActivity"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity2"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="false">
</activity>
</application>
</manifest>
//My MainActivity
//MainActivity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.READ_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, arrayOf(android.Manifest.permission.READ_CALL_LOG), 101)
displayLog()
}
}
private fun displayLog() {
var cols= arrayOf(CallLog.Calls._ID, CallLog.Calls.NUMBER, CallLog.Calls.TYPE, CallLog.Calls.DURATION,CallLog.Calls.DATE)
var rs=contentResolver.query(CallLog.Calls.CONTENT_URI,cols,null,null, "${CallLog.Calls.LAST_MODIFIED} DESC")
var from= arrayOf(CallLog.Calls.NUMBER,CallLog.Calls.DURATION,CallLog.Calls.TYPE)
val adapter=SimpleCursorAdapter(this, R.layout.mylayout,rs,from, intArrayOf(R.id.textView1,R.id.textView2,R.id.textView3),0)
val listview=findViewById<ListView>(R.id.listview) as ListView
listview.adapter=adapter
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if(requestCode==101 && grantResults[0]==PackageManager.PERMISSION_GRANTED) {
displayLog()
}
}
}
Change your if block to this , you are not handling the case when permission is already given.
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.READ_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, arrayOf(android.Manifest.permission.READ_CALL_LOG), 101)
}else{
displayLog()
}
I am trying to create payment app which support the tap & pay functionality. I am already done with the Connecting App to NFC terminal with use of SELECT APDU Command.
Now, I want to send the stored card details from app to NFC Terminal, so it can make transaction.
Can you suggest me any kind of documents, which can help me to achieve it, such as how to send the details securely and in what kind of format it should be send?
any help would be appreciated.
here is the code
Android Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nfcemulator">
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc.hce"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.NFCEmulator">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".service.HCEService"
android:exported="true"
android:permission="android.permission.BIND_NFC_SERVICE">
<intent-filter>
<action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" />
</intent-filter>
<meta-data
android:name="android.nfc.cardemulation.host_apdu_service"
android:resource="#xml/apduservice" />
</service>
</application>
</manifest>
HCE Service
class HCEService: HostApduService() {
companion object {
val TAG = "Host Card Emulator"
val STATUS_SUCCESS = "9000"
val STATUS_FAILED = "6F00"
val CLA_NOT_SUPPORTED = "6E00"
val INS_NOT_SUPPORTED = "6D00"
val AID = "A0000002471001"
val SELECT_INS = "A4"
val DEFAULT_CLA = "00"
val MIN_APDU_LENGTH = 12
}
override fun onDeactivated(reason: Int) {
Log.d(TAG, "Deactivated: " + reason)
}
override fun processCommandApdu(commandApdu: ByteArray?, extras: Bundle?): ByteArray {
if (commandApdu == null) {
return Utils.hexStringToByteArray(STATUS_FAILED)
}
val hexCommandApdu = Utils.toHex(commandApdu)
if (hexCommandApdu.length < MIN_APDU_LENGTH) {
return Utils.hexStringToByteArray(STATUS_FAILED)
}
if (hexCommandApdu.substring(0, 2) != DEFAULT_CLA) {
return Utils.hexStringToByteArray(CLA_NOT_SUPPORTED)
}
if (hexCommandApdu.substring(2, 4) != SELECT_INS) {
return Utils.hexStringToByteArray(INS_NOT_SUPPORTED)
}
if (hexCommandApdu.substring(10, 24) == AID) {
return Utils.hexStringToByteArray(STATUS_SUCCESS)
} else {
return Utils.hexStringToByteArray(STATUS_FAILED)
}
}
}
apduservices.xml
<?xml version="1.0" encoding="utf-8"?>
<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
android:description="#string/hce_service"
android:requireDeviceUnlock="false">
<aid-group android:description="#string/aid_groups"
android:category="other">
<aid-filter android:name="325041592E5359532E4444463031"/>
</aid-group>
</host-apdu-service>
I’m having some trouble getting Google Assistant to play media for my media app.
I have verified using the Media Controller Tester app that the play actions are working. I am able to use Open Feature Actions with Assistant.
But every time I try to use phrases like Play AppName or Play Station on AppName, Assistant tries to launch TuneIn.
If I try Play music on AppName Assistant launches YouTube Music .
I have tried everything in the docs here and have used UAMP as a base (of which I am also seeing similar behaviour)
Here is a cut down version of my audio service:
class AudioService : MediaBrowserServiceCompat() {
#Inject
lateinit var audioServiceBrowserManager: AudioServiceBrowserManager
#Inject
lateinit var schedulerProvider: RxSchedulerProvider
#Inject
lateinit var playbackPreparer: AppPlaybackPreparer
#Inject
lateinit var playbackControlDispatcher: AppControlDispatcher
#Inject
lateinit var audioProvider: AudioProvider
#Inject
lateinit var playbackManager: PlaybackManager
#Inject
lateinit var mediaSessionChangedCallback: MediaSessionChangedCallback
private lateinit var mediaSession: MediaSessionCompat
private lateinit var mediaSessionConnector: MediaSessionConnector
private lateinit var mediaController: MediaControllerCompat
private lateinit var audioNotificationManager: AudioNotificationManager
private lateinit var packageValidator: PackageValidator
private val disposables = CompositeDisposable()
companion object {
private const val SEEK_BACKWARD_INCREMENT = 15000
private const val SEEK_FORWARD_INCREMENT = 30000
private const val MEDIA_SESSION_TAG: String = "AudioService"
internal const val METADATA_MEDIA_TYPE = "au.net.app.player.service.metadata.mediaType"
internal const val METADATA_MEDIA_TYPE_ONDEMAND_VIDEO = 0L
internal const val METADATA_MEDIA_TYPE_ONDEMAND_AUDIO = 2L
internal const val METADATA_MEDIA_TYPE_LIVE = 1L
val DEFAULT_PLAYBACK_STATE: PlaybackStateCompat = PlaybackStateCompat.Builder()
.setState(PlaybackStateCompat.STATE_NONE, PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0f)
.build()
}
override fun onCreate() {
AndroidInjection.inject(this)
super.onCreate()
mediaSession = MediaSessionCompat(this, MEDIA_SESSION_TAG).apply {
setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS or MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS)
isActive = true
}
sessionToken = mediaSession.sessionToken
mediaSessionConnector = MediaSessionConnector(mediaSession).apply {
setRewindIncrementMs(SEEK_BACKWARD_INCREMENT)
setFastForwardIncrementMs(SEEK_FORWARD_INCREMENT)
setPlaybackPreparer(playbackPreparer)
setQueueNavigator(AppQueueNavigator(mediaSession, audioProvider, this#AudioService, this))
setControlDispatcher(playbackControlDispatcher)
setPlayer(playbackManager.currentPlayback.playerImpl)
registerCustomCommandReceiver(playbackManager.mediaSessionCommandReceiver)
}
disposables.add(
playbackManager.currentPlaybackObservable.subscribe { currentPlayback ->
mediaSessionConnector.setPlayer(currentPlayback.playerImpl)
}
)
mediaController = MediaControllerCompat(this, mediaSession)
mediaController.registerCallback(mediaSessionChangedCallback)
try {
audioNotificationManager = AudioNotificationManager(this, mediaController)
} catch (e: RemoteException) {
throw IllegalStateException("Could not create a MediaNotificationManager", e)
}
packageValidator = PackageValidator(this, R.xml.allowed_media_browser_callers)
}
private var currentLoadChildrenDisposable: Disposable? = null
override fun onLoadChildren(parentId: String, result: Result<MutableList<MediaBrowserCompat.MediaItem>>) {
Timber.d("""
onLoadChildren(
parentId = $parentId,
result = $result
)
""".trimIndent())
}
override fun onGetRoot(clientPackageName: String, clientUid: Int, rootHints: Bundle?): BrowserRoot? {
Timber.d("""
onGetRoot(
clientPackageName = $clientPackageName,
clientUid = $clientUid,
rootHints = $rootHints
)
""".trimIndent())
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
super.onStartCommand(intent, flags, startId)
return START_STICKY
}
override fun onTaskRemoved(rootIntent: Intent?) {
super.onTaskRemoved(rootIntent)
playbackManager.handleStop()
stopSelf()
}
override fun onDestroy() {
super.onDestroy()
playbackManager.handleStop()
disposables.dispose()
mediaSession.isActive = false
mediaSession.release()
}
}
The module manifest (note - the service is not in my main app module)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="au.net.app.player.service">
<uses-permission android:name="android.permission.INTERNET" />
<application>
<service
android:name="au.net.app.player.service.AudioService"
android:exported="true">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>
<receiver android:name="androidx.media.session.MediaButtonReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="#xml/automotive_app_desc" />
</application>
</manifest>
In the main app manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="au.net.app"
android:installLocation="auto">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:name=".AppApplication"
android:allowBackup="true"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:networkSecurityConfig="#xml/network_security_config"
android:supportsRtl="true"
android:hardwareAccelerated="true"
android:theme="#style/AppTheme">
<activity
android:name=".mainscreen.MainActivity"
android:launchMode="singleTask"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar"
android:resizeableActivity="true"
android:supportsPictureInPicture="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Intent filters to open Feature screens -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="feature"
android:pathPattern="/.*"
android:scheme="${APP_SCHEME}" />
</intent-filter>
<!-- Declares that the app handles SEARCH intent for media playback -->
<!-- This is mandatory for Android Auto support: -->
<!-- https://stackoverflow.com/questions/31953155/android-auto-voice-cannot-perform-play-x-on-y/31976075#31976075 -->
<intent-filter>
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Required for Google Assistant integration -->
<meta-data android:name="com.google.android.actions" android:resource="#xml/actions" />
</application>
</manifest>
I have also tried setting up my playback state with:
val DEFAULT_PLAYBACK_STATE: PlaybackStateCompat = PlaybackStateCompat.Builder()
.setActions(getSupportedActions())
.setState(PlaybackStateCompat.STATE_NONE, PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0f)
.build()
private fun getSupportedActions(): Long {
return PlaybackStateCompat.ACTION_PLAY or
PlaybackStateCompat.ACTION_PLAY_FROM_SEARCH or
PlaybackStateCompat.ACTION_SKIP_TO_NEXT or
PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS or
PlaybackStateCompat.ACTION_PLAY_PAUSE
}
But my understanding is I shouldn't need to as MediaSessionConnector should take care of that (since I am using ExoPlayer). Adding this does not help.
I have an app that, when is first installed a splash screen appears and then a intro with 3 fragments appears and explains how the app works. However once the user walked through that "intro" only the splash screen appears. How should I do that? I belive this has to do my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.pfinal">
<!-- Permissoes para o acesso a camera -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- Permissoes para o acesso ao GPS -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_fire_round"
android:label="AppFogos"
android:roundIcon="#mipmap/ic_fire_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".Intro">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- The below is for the splash screen and we need no action bar and the default theme -->
<activity
android:name=".SplashScreen"
android:theme="#style/AppTheme.NoActionBar">
<!-- <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>-->
</activity>
<activity android:name=".AppFogos" />
<activity android:name=".HomePage">
<!-- <intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>-->
</activity>
</application>
Intro is the activity with the walktrough and SplashScreen is the activity with the splash screen.
Right now, only the Intro appears.
Here is the code for the "Intro":
val fragment1 = SliderFragment()
val fragment2 = SliderFragment()
val fragment3 = SliderFragment()
lateinit var adapter : myPagerAdapter
lateinit var activity: Activity
lateinit var preference : SharedPreferences
val pref_show_intro = "Intro"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_intro)
activity = this
preference = getSharedPreferences("~PFinal", Context.MODE_PRIVATE)
if(!preference.getBoolean(pref_show_intro,true)){
startActivity(Intent(activity,SplashScreen::class.java))
finish()
}
fragment1.setTitle("welcome")
fragment2.setTitle("fogos")
fragment3.setTitle("o que utilizamos")
adapter = myPagerAdapter(supportFragmentManager)
adapter.list.add(fragment1)
adapter.list.add(fragment2)
adapter.list.add(fragment3)
view_pager.adapter = adapter
next.setOnClickListener {
view_pager.currentItem++
}
skip.setOnClickListener { goToHomePage() }
view_pager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener{
override fun onPageScrollStateChanged(state: Int) {
}
override fun onPageScrolled(
position: Int,
positionOffset: Float,
positionOffsetPixels: Int
) {
}
override fun onPageSelected(position: Int) {
if(position == adapter.list.size-1)
{
//lastpage
next.text="DONE"
next.setOnClickListener {
goToHomePage()
}
}else{
next.text="NEXT"
next.setOnClickListener {
view_pager.currentItem++
}
}
when(view_pager.currentItem)
{
0->{
indicator1.setTextColor(Color.BLACK)
indicator2.setTextColor(Color.GRAY)
indicator3.setTextColor(Color.GRAY)
}
1->{
indicator1.setTextColor(Color.GRAY)
indicator2.setTextColor(Color.BLACK)
indicator3.setTextColor(Color.GRAY)
}
2->{
indicator1.setTextColor(Color.GRAY)
indicator2.setTextColor(Color.GRAY)
indicator3.setTextColor(Color.BLACK)
}
}
}
})
}
fun goToHomePage(){
startActivity(Intent(activity,HomePage::class.java))
finish()
val editor = preference.edit()
editor.putBoolean(pref_show_intro,false)
editor.apply()
}
class myPagerAdapter(manager : FragmentManager): FragmentPagerAdapter(manager){
val list : MutableList<Fragment> = ArrayList()
override fun getItem(position: Int): Fragment {
return list[position]
}
override fun getCount(): Int {
return list.size
}
}