enter code here
BackgroundService-Lorsque vous utilisez la bulle flottante en tant que service d'arrière-plan pour prendre une capture d'écran de l'écran en direct. Obtenir deux erreurs
private void addNewBubble()//ERROR , Expression expected and Missing ';' token{
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
//here is all the science of params
final WindowManager.LayoutParams myParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
PixelFormat.TRANSLUCENT
);
BubbleLayout bubbleView = (BubbleLayout) LayoutInflater.from(BackgroundService.this).inflate(R.layout.bubble_layout, null);
bubbleView.setLayoutParams(myParams);
bubbleView.setOnBubbleRemoveListener(new BubbleLayout.OnBubbleRemoveListener() {
@Override
public void onBubbleRemoved(BubbleLayout bubble) {
}
});
bubbleView.setOnBubbleClickListener(new BubbleLayout.OnBubbleClickListener() {
@Override
public void onBubbleClick(BubbleLayout bubble) {
Bitmap b = Screenshot.takescreenshotOfRootView(imageView);
imageView.setImageBitmap(b);
main.setBackgroundColor(Color.parseColor("#999999"));
//Toast.makeText(getApplicationContext(), "Clicked !",
// Toast.LENGTH_SHORT).show();
}
});
bubbleView.setShouldStickToWall(true);
bubblesManager.addBubble(bubbleView, 60, 20);
}
}
private void initializeBubblesManager() {
bubblesManager = new BubblesManager.Builder(this)
.setTrashLayout(R.layout.bubble_trash_layout)
.setInitializationCallback(new OnInitializedCallback() {
@Override
public void onInitialized() {
addNewBubble();// ERROR
}
})
.build();
bubblesManager.initialize();
}
}
Ceci est la méthode OnStart qui comprend toutes les méthodes pour créer la bulle flottante et de le rendre cliquable de prendre une capture d'écran. Seul addNewBubble affiche des erreurs, alors que lorsque le code Floating Bubble est exécuté sur MainActivity sans la création de BackgroundService, il fonctionne correctement sans aucune erreur. Des suggestions sur ce qu'il faut faire?
Je suis nouveau à stackoverflow, s'il vous plaît aidez-moi. J'ai vérifié ici et ne peux pas sembler trouver une erreur semblable. – Yohanelly
Copie possible de [autorisation Android refusée pour le type de fenêtre 2010 dans Marshmallow ou supérieur] (https://stackoverflow.com/questions/37982167/android-permission-denied-for-window-type-2010-in-marshmallow-or- supérieur) – ventiseis
Oui j'ai lu ceci, l'erreur est similaire. Mais mon code est radicalement différent, j'ai compilé 'com.txusballesteros: bubbles: 1.2.1' – Yohanelly