last day (16 days later) » 

19:59
0
Q: Launching an activity from another activity skips a lot (96) frames

GreyfrogI have an app which had two activities - LoginActivity (LA) and AppActivity (AA). As you have guessed, LA launches AA upon successful log. For the debugging purpose, I removed all the login logic and replaced it with the simple button to launch AA. AA containes on Fragment which contain a viewpag...

can you add AppActivity's code
I figured out one of three skipping frame warning. I was initializing TTS engine - engine = TextToSpeech(this, this) in onCreate inside AppAcitvity which was causing 84 frames skips so I commented out and now I only get two warning for skipping frames instead of three.
Well then, now you don't need that?
No, I need that so I am putting it inside a thread. Right now I am trying to figure out other two warning for skipping frames.
If you can add the code, you can be helped
19:59
okay let me add it
@rahat I have updated my question. please read the new update too Thank you.
Hey, you gave the changed code
yess
If you could give the original code especially of the oncreate()
also, I noticed I can't initialize engine inside a thread because it crashes the app
just the onCreate() ?
okay
yes but original
20:01
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_app)
val toolbar: Toolbar = findViewById(R.id.toolbar)
setSupportActionBar(toolbar)

val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
val navView: NavigationView = findViewById(R.id.nav_view)
val navController = findNavController(R.id.nav_host_fragment)
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
appBarConfiguration = AppBarConfiguration(setOf(
R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow), drawerLayout)
observers() who is this guy?
this guys just observe message from other fragments and feed it to tts
wait I will share
private fun observers(){
fusionViewModel.getMessage().observe(this,{ msg ->
playMessage(msg)
})
}
ok
and in the original code are you doing some thing in onstart or on resume?
no
they weren't even implemented
just onCreate
I don't understand this -- I have moved TTS engine initialization inside thread and I still get fram drops. Not as significant as before but I still get frame drop like 35 frames

Thread(Runnable {
engine = TextToSpeech(this, this)
}).start()
20:27
Hi Rahat if you check back -- I am creating a viewpager and one of the view is loading music from local storage and populating them in the list.

I have implemented this method to play and pause when your click on the list -

musicAdapter?.setOnItemClickListener(object : OnRVItemClickListener {
override fun OnItemClick(pos: Int) {
if (pos == currSong && mediaPlayer != null) {
/* play pause same song*/
playPause()
} else {
/* start a new song from the list*/
playContentUri(musicList.get(pos).uri, musicList.get(pos).title)
This is the play pause method

private fun playPause(){
if (mediaPlayer!!.isPlaying) {
mediaPlayer!!.pause()
playerUI(false, R.drawable.ic_play_circle_outline_24px)
}else{
mediaPlayer!!.start()
playerUI(true, R.drawable.ic_pause_circle_outline_24px)
}
}
...

So the problem I have here is, when I swipe between my views from viewpager I see CPU usage goes up and comes back to zero. When I start the music from the list, CPU usage goes up and remain up during the play time... what I expect is when I pause or stop music CPU usage should go back to zero
but CPU usage remain up and doesn't become zero even if I have stopped or paused the music.
when I swipe the views and come back to this view again, CPU usage become zero. Means I would have to swipe between views after pausing music to make CPU usage zero.

  last day (16 days later) »