1

我在Android Nougat中使用原始音樂播放器,而音樂在鎖定屏幕中播放在Buttom中出現動畫,如此屏幕截圖。Android Nougat Media Player如何將音樂動畫放入鎖定屏幕?

enter image description here

但是,當我在鎖屏用我自己的App媒體播放器在同一臺Android牛軋糖和相同的設備不出現的動畫。

enter image description here

的問題是:我如何才能加入該動畫在我的媒體播放器應用程序?它不是gif圖像,因爲動畫會移動到音樂的節奏。

**這是我的通知方法**如果我錯過了某些東西或者我需要添加其他東西。

ublic void Custom_Notificacion(){ 

    Notification notification = new Notification(R.drawable.logobubble, null, System.currentTimeMillis()); 

    notificationView = new RemoteViews(getPackageName(), R.layout.layout_notificacion_personalizada); 

    notificationView.setImageViewBitmap(R.id.id_FotoAlbumNotif,FotoNotif); 
    notificationView.setTextViewText(R.id.id_NombreMp3Notif,NommbreArtista); 
    notificationView.setTextViewText(R.id.id_NombreCancionNotif,NombreCancion); 

    notification.contentView = notificationView; 
    notification.flags |= Notification.FLAG_NO_CLEAR; 

    startForeground(constantes.NOTIFICATION_ID.FOREGROUND_SERVICE,notification); 

} 

回答

1

我讀過有關這方面的文章,一個可行的解決方案是自定義鎖屏頁面,並在其中顯示動畫視圖,實現這一目標需要一個服務聽LOCK_SCREEN廣播,並開始您的LockScreenActivity;同時更換系統鎖定屏幕。 這裏是一些代碼段可能會有所幫助: 註冊廣播接收器

IntentFilter mScreenOffFilter = new IntentFilter(); 
mScreenOffFilter.addAction(Intent.ACTION_SCREEN_OFF); 
registerReceiver(mScreenOffReceiver, mScreenOffFilter); 

//在接收方法

private BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() { 
@SuppressWarnings("deprecation") 
@Override 
public void onReceive(Context context, Intent intent) { 
    if (intent.getAction().equals(NOTIFY_SCREEN_OFF)) { 
     Intent mLockIntent = new Intent(context, LockScreenActivity.class); 
     mLockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK 
       | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); 
     startActivity(mLockIntent); 
    } 
} 

禁用鎖定屏幕

KeyguardManager mKeyguardManager = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE); 
KeyguardManager.KeyguardLock mKeyguardLock = mKeyguardManager.newKeyguardLock("CustomLockScreen"); 
mKeyguardLock.disableKeyguard(); 

希望這可以有點幫助

+0

我會試試這個,謝謝你的anwser,如果這個工程我會返回。 –

相關問題