Custom recent history image in Android - android

Is there a way or workaround to achieve custom image showing in app's recent history ?
I know the android activity already given for such case :
#Override
public boolean onCreateThumbnail (Bitmap outBitmap, Canvas canvas) {
// draw custom image here.
return true;
}
But unfortunately this method is never called.
So anyone knows how can possibly achieve that ?
Any ideas welcome.

Related

Android detect or block floating/overlaying apps

Android enables apps to draw over other apps with android.permission.SYSTEM_ALERT_WINDOW and it's called a floating/overlaying app. For example Facebook Messenger has always visible chat bubbles at the edges of screen.
My question is: Is it possible to detect or block in Java code any app which draws over my app?
There is a View#onFilterTouchEventForSecurity() method you can override to detect if the motion event has the FLAG_WINDOW_IS_OBSCURED. This will let you know if something is drawn on top of your view.
#Override
public boolean onFilterTouchEventForSecurity(MotionEvent event) {
if ((event.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) == MotionEvent.FLAG_WINDOW_IS_OBSCURED){
// show error message
return false;
}
return super.onFilterTouchEventForSecurity(event);
}
If you just want to protect your app from tap jacking due to another app drawing over your app you can add setFilterTouchesWhenObscured to your views via XML or programmatically.

How to change color dynamically on a circle programmatically

Update: Thx for the answers, problem solved.
Yes code is missing, I am using Mapsforge library.
It had nothing to do with anything else than a bad comparison in a sqlite lookup
which resulted no calling of toggleColor(). Now it works just fine!
Hi I am having trouble changing the color of a circle drawn on a canvas. The other color represents a different state of the circle.
It works fine with onTap i.e when I tap the circle on the screen, but when I try to do it programmatically like
circle.toggleColor() and then
circle.requestRedraw() nothing happens.
How can I make this work programmatically?
#Override
public boolean onTap(LatLong geoPoint, Point viewPosition, Point tapPoint) {
if (this.contains(viewPosition, tapPoint)) {
toggleColor();
this.requestRedraw();
return true;
}
return false;
}
#Override
private void toggleColor() {
if (this.getPaintFill().equals(LongPressAction.GREEN)) {
this.setPaintFill(LongPressAction.RED);
} else {
this.setPaintFill(LongPressAction.GREEN);
}
}
Thx for answering
Yes code is missing in the snippet, I am using Mapsforge library.
It had nothing to do with anything else than a bad comparison in a sqlite lookup which resulted no calling of toggleColor(). Too much time spent on chasing that stupid mistake...
Now it works just fine!

Is it possible to change the black background color of android app drawer programmatically?

I'm working on an android apk in which the app drawer background is changed. I have searched through the internet. I have found 2 methods to change the app drawer's black background.
First one is using apktool, which decompiles launcher.apk and builds it back to apk format. In between the programmer do the required changes ( res/values/colors , background="..." ). Then sign and move it back to system/app folder.
Second one is using another application like GO Launcher, but I have to use my own application to change the black background color programmatically.
Is there a way to achieve this ( in eclipse for example ) ?
Thank you for your supports and answers in advance.
Here is an example for your requirement (programatically):
redBtn.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
Log.d("MYAPP", "RED touched..");
setActivityBackgroundColor(Color.RED);
return false;
}
});
The function defination for setActivityBackgroundColor(); is given below:
public void setActivityBackgroundColor(int color) {
View view = this.getWindow().getDecorView();
view.setBackgroundColor(color);
}
This worked for me, you can modify same as per your requirement.
Accept the answer if it meets your requirement.
-Regards

Create a picture on Android

I want to create a picture to send a website on android. But It must be background.. let me explain more..
the picture is what i want http://e1203.hizliresim.com/v/r/3s06c.png
I have some photo which I want to put on the main picture. and I'll write some text near of photos.. and will create (draw)a big main photo.. But It must process background..
I think that I need to use drawing but I dont have any idea how can I create like that picture..
I hope I could explain my problem..
You need to use the Canvas class:
You need to do something like this:
class Panel extends View {
public Panel(Context context) {
super(context);
}
#Override
public void onDraw(Canvas canvas) {
canvas.drawBitmap(...);
canvas.drawText(...);
}
}
Look at this tutorial for details.

Android 4.0: canvas.setViewport error

I'm getting an error in my code.
the method setViewPort(int, int) cannot be defined for the type canvas.
I am trying to implement multi touch functionality on an ImageView, the intire class is far too long to put up here but if you require more information just comment.
#Override
protected void onDraw(Canvas canvas) {
if(layout) {
if(!viewSet) {
//line that's causing issue
canvas.setViewport(displayWidth, displayHeight);
viewSet = true;
}
can't figure out what the issue is, have all necessary imports etc.
Would it be the fact I'm using Android 4.0?
thanks.
Shaw
Here's the answer from Romain Guy from the Google Group:
"This method was removed because it had no effect whatsoever. It was a
remnant of an old and failed experiment."

Categories

Resources