Some note about Android

Today’s note 2017-05-27

  • Floating window in Android (WindowManager,Toast)
  • play m3u8 by Exoplayer
  • check installed app
  • check the permission
  • create a Popwindow
  • SharedPreferences

Floating window in Android

1
2
3
4
5
6
7
8
9
10
11
12
//1,get a WindowManager by using 
getApplication().getSystemService(Context.WINDOW_SERVICE)
//or using
Activity.this.getWindowManager() //it only can be used on the activity it belongs to

//2,set the WindowManager.LayoutParams :type(TYPE_SYSTEM_ALERT),format,flags,gravity and x,y ,width,height (LayoutParams.WRAP_CONTENT)

//3,then add the view
windowManager.addView(View,LayoutParams)

//4,remove when it no longer needed
windwoManager.removeView(View)

play m3u8 by Exoplayer

1
2
3
//1,prepare the TrackSelector  ..(BandwidthMeter,) about the newwork
//2,prepare the source ..() about the uri ,app which called it we can find some kind of source
//3,new a ExoPlayer and prepare the source

check installed packages

check permission