Override Pending Transition not working on android n - android-studio

Im finishing my activity with an animation and before android n, they worked fine but now the activity just disappears without the transition. Is this a bug or something?
#Override
public void finish() {
super.finish();
//Worked before android n
overridePendingTransition(R.anim.slide_up, R.anim.slide_down);
}

Related

Progress is not increasing in progress dialog Android Studio

I am using the following code in Android Studio:
final ProgressDialog pr1 = new ProgressDialog(this);
pr1.setMessage("Loading... ");
pr1.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pr1.setIndeterminate(true);
pr1.setProgress(0);
pr1.setMax(99);
pr1.show();
final Thread t1 = new Thread(new Runnable() {
#Override
public void run() {
int i;
for(i=0;i<=99;i++) {
//some code here
pr1.incrementProgressBy(1);
}
pr1.dismiss();
}
});
t1.start();
now whenever i run this, progress dialog shows and run but the progress bar can not increment its just showing off.
You cannot show increment in an indeterminate progressbar.
As per the Android docs: "In indeterminate mode, the progress bar shows a cyclic animation without an indication of progress."
If you want to show progess you have to change your line setIndeterminate(true) and make it false.

Action listeners not firing

I've been developing with codenameone for over a year, and I never ran into this problem before, I feel like I'm losing my mind. I just redesigned one part of an app I'm working on, and now the ActionListeners aren't firing. I'm attaching them to a Button and a SpanButton in the code:
ActionListener goToDoc = new ActionListener() {
String mDocId = docId;
#Override
public void actionPerformed(ActionEvent evt) {
mStateMachine.currentExpertId = mDocId;
mStateMachine.showForm("DoctorDetails", null);
}
};
name.addActionListener(goToDoc);
Util.downloadImageToStorage(mStateMachine.URL_PREFIX+"images/doctors/"+(String)value.get("doc_pic"),
"doc_post_pic_"+(String)value.get("doc_id")+".png", new Callback<Image>() {
#Override
public void onSucess(Image img) {
pic.setIcon(img.scaledWidth(mStateMachine.getProportionalWidth(.23)));
StateMachine.applyGreenBorder(pic);
pic.addActionListener(goToDoc);
pic.getParent().revalidate();
}
#Override
public void onError(Object sender, Throwable err, int errorCode, String errorMessage) {
System.out.println("Unable to download expert profile picture");
}
});
When I debug the code, the components do show that the ActionListener is attached, but the actionPerformed method is never reached, no matter how many times I click on the buttons. I experience this problem both on the simulator and on an Android device. I have yet to test on an iPhone.
Did you set a parent to be a lead component or focusable?
The reason the click event wasn't firing was because the Components weren't enabled, possibly a bug in the BUI Builder. After checking off the 'Enabled' and 'Focusable' checkboxes in the GUI Builder, and seeing they were unchecked every time I went back to that form, I just used component.setFocusable(true) and component.setEnabled(true) in the code, and it worked fine after that.

LibGDX DragAndDrop - Drag stop is called immidiatly after drag

Im currently developing a basic game for Android, but I'm having a big problem with the com.badlogic.gdx.scenes.scene2d.utils library.
When I started the project I used Eclipse and the DragAndDrop-functionality worked great, but after a while I experienced problems with Gradle which led me to change to Android Studio. So after exporting my project to Android studio, the DragAndDrop just stopped working. When I click a dragobject and start to drag it, it stops immediately and DragStop() is called.
Now I feel I have tried everything there is and the only lead is this thread: https://github.com/libgdx/libgdx/issues/2901 which is basicly the same behavior, but it's caused by something else. By "lead" I mean that maybe the change of LibGDX version is the problem? I have not investigated this any further.
Anyway, I can't even get this simple DragAndDrop example to work:
dragAndDrop = new DragAndDrop();
dragAndDrop.addSource(new DragAndDrop.Source(splashActor)
{
#Override
public DragAndDrop.Payload dragStart(InputEvent event, float x,
float y,int pointer)
{
DragAndDrop.Payload payload = new DragAndDrop.Payload();
payload.setObject(splashActor);
payload.setDragActor(splashActor);
return payload;
}
});
dragAndDrop.addTarget(new DragAndDrop.Target(pauseButton)
{
#Override
public boolean drag(DragAndDrop.Source source, DragAndDrop.Payload payload,
float x, float y, int pointer)
{
return true;
}
#Override
public void drop(DragAndDrop.Source source, DragAndDrop.Payload payload,
float x, float y, int pointer)
{
}
});
Thanks for any help or ideas regarding this problem. I would be truly grateful if I could get my game working again!
This problem was fixed by updating the libgdx version to 1.5.5-SNAPSHOT! Thanks to noone for solving this.

Android frame animation delays the navigation drawer speed

I am using the navigation drawer. I want to use a frame animation as background in my main activity with the navigation drawer.
But the navigation drawer opening and closing speed becomes slow when frame animation is started. So I tried the following:
#Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
frameAnimation.start();
}
#Override
public void onDrawerOpened(View drawerView) {
frameAnimation.stop();
super.onDrawerOpened(drawerView);
}
This code does the close drawer in a smooth way. But opening still causes some delay. Is there any way to sort it.
Try giving a small delay to the animation stop and start calls. You can experiment with the delay value. Using 450ms here.
Handler handler = new Handler();
handler.postDelayed(new Runnable(){
public void run(){
frameAnimation.stop();
}
},450);
handler.postDelayed(new Runnable(){
public void run(){
frameAnimation.start();
}
},450);

How can I develop a custom "non-fullscreen" softkeyboard for tablets?

I have the sample of softkeyboard. When I install it on a android 2.x, it has the following non-fullscreen view:
But when I install it on tablet 10in it gets whole of the screen like this:
How can I change the sample to have a non-fullscreen custom keyboard on tablet pcs like this image (default keyboard of tablet)?
The following code in InputMethodService solved my problem:
#Override
public boolean onEvaluateFullscreenMode() {
return false;
}
overide the following two methods from InputmethodService as bellow, this works always
#Override
public void onUpdateExtractingVisibility(EditorInfo ei) {
// TODO Auto-generated method stub
setExtractViewShown(false);
}
#Override
public boolean onEvaluateFullscreenMode() {
return false;
}
This worked for me :) and if you want to show keyboard in fullscreen mode always then change both false to true.

Resources