[Q] activity change problem - Android Q&A, Help & Troubleshooting

Hi!
I'm developing an android app. This app have got 3 activity. On the first activity i have two button. the first button is navigate the user the second activity, and the second activity navigate to the third activity.
the second button on the first activity is use the phone camera, and i would like to navigate to the third activity, but my app dont do this.
If i click on the second button on first activity the app show me the third activity, and after the third activity show me the camera.
I use this code to change activitys:
Code:
Intent kapcsolat = new Intent(v.getContext(), SECONDACTIVITY.class);
startActivity(kapcsolat);
and i use this code to use the phone camera:
Code:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
fileuri = getOutputMediaFileUri(KEP);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileuri);
startActivityForResult(intent, kamera_kep);
My second button code:
Code:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
fileuri = getOutputMediaFileUri(KEP);
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileuri);
startActivityForResult(intent, kamera_kep);
Intent kapcsolat = new Intent(v.getContext(), SECONDACTIVITY.class);
startActivity(kapcsolat);
Could you help me in my problem?
Now my app work as this:
First activity -> second button -> Third Activity -> Camera activity
But i would like to work as this:
First activity -> second button ->Camera activity -> Third Activity
sorry for my bad english, i hope you understand me.

Related

[Q] Capture raw soft-keyboard events

Hi all
I have an issue with an app I am writing. It has the working name VNCHID, and is designed to allow an Android phone/tab to be used as a keyboard and mouse for a computer (or other device) over VNC. I currently have it in a semi-working state, but with unpredictable results. I am hoping someone can help with the issues I have come accross.
The first is related to mapping KeyEvents to VNC (X11) KeySyms. I have derived a class from KeyEvent wrich adds a method "getKeySym". This method does the following:
Uses the getUnicodeCharacter method from KeyEvent to try to determine a character from the key (combination). If one exists, it uses a map (found elsewhere) to translate this into a KeySym.
Does the same again, but without modifier keys. This may be unnecessary, but for now I have left it in.
Assuming the above fails, it uses getKeyCode and runs this through my own map to generate a KeySym.
The problem I am facing on my development device, an A10-based tablet running CM9, is that if a key is pressed which doesn't have a unicode character associated with it, like backspace, the code just stops at getUnicodeCharacter. It doesn't crash the app, throw an exception, or anything else, the execution of the routine just stops completely. It will still pick up other keyevents afterwards.
This seems very strange, and I do not know why it would do so.
My second problem is on my day-to-day phone. I tried installing the app on here to see if the problem was with the device/ROM/etc, but on here it doesn't even detect any keyevents. I have done some research which indicates that my approach (implementing OnKeyListener) is not guaranteed to work with soft keyboards, but it seems very strange that it (almost) does on one device but not on another (using the same soft keyboard, hackers keyboard).
I am now almost at the stage of creating my own keyboard (not an IME, just a layout to be shown in the app with a keyboard), but would like to avoid this. Can anyone help? I am tearing my hair out. Does anyone know the correct way to receive keyevents from a soft keyboard? I do not want an edittext, I just want the raw key events.
The code for my getKeySym() method is bellow. It stops at the first getUnicodeCharacter() call when a non-character key is pressed:
Code:
// Test unicode
Log.i("VNCHID.VKE","Translating keyevent to keysym");
int keysym=0, ucc=0;
ucc=this.getUnicodeChar(this.getMetaState());
Log.i("VNCHID.VKE","Got ucc");
if( ucc > 0 ) {
keysym = UnicodeToKeysym.translate(ucc);
}
if( keysym > 0 ) {
Log.i("VNCHID.VKE", "Got keysym "+keysym+" from ucc "+ucc);
return keysym;
}
// Test unicode without modifiers
ucc=this.getUnicodeChar(0);
if( ucc > 0 ) {
keysym = UnicodeToKeysym.translate(ucc);
}
if( keysym > 0 ) {
Log.i("VNCHID.VKE", "Got keysym "+keysym+" from ucc wom "+ucc);
return keysym;
}
Log.i("VNCHID.VKE","Could not find keysym from ucc, trying from keycode");
// Otherwise lookup from KeyCode
if( KCSM.size() < 1 ) generateKeyCodeSymMap();
/*KCSM.
if( KCSM.containsKey(this.getKeyCode()) ) return KCSM.get(this.getKeyCode());
*/
keysym=KCSM.get(this.getKeyCode(), -1);
Log.i("VNCHID.VKE","Result of lookup by keycode "+this.getKeyCode()+" is "+keysym);
return keysym;
Note it was much simpler, but I have expanded it and inserted the Log calls for debugging. As an example, when backspace is pressed I receive log lines from my onKey method, plus the first one in this method (Translating keyevent to keysym) but nothing after that.
Please help!
Hi
Is this the right forum to be asking questions like this? I'm not trying to be pushy, it's just I've come to expect quick, helpful answers on this site, so I just wanted to double check.
If so... Bump
If not, could someone please point me towards the appropriate forum?
Sent from my MB860 using xda premium

[Q] XML of app being shown instead of the app itself

Jul 11
Hello All,
I have an issue in my App.
I have three activities called A , B ,C
In the activity A I have a button and onclick of that I open another Activity called ShowChart.Onback press of ShowChart Activity I navigate to Activity A
Onback press of Activity A I close the App.
Following is the Problem
------------------------------------------
When I open ShowChart Activity and do backpress I go to Activity A which is fine but when I again do back press from Activity A my App gets Closed but XML of the
ShowChart Activity is shown instead of normal close of the App.
Any Help would be appreciated.Thanks in Advance

[Q] App to perform the same effect as the touch button task shifting

Good evening, I'm a newbie, I read about intent, activity and other things in Android but can not get the effect I want.
I would make exactly the same action that causes the button to the left. "switch between tasks" of a Galaxy Tab 4. Run the code in my application and pass to any previously opened application.
I've tried several codes like this, and I've also searched some information about the PID of the process, but I know not to handle them too well:
Intent intent1 = new Intent(Intent.ACTION_VIEW); // OR ACTION_MAIN ??
intent1.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT );
intent1.addCategory(Intent.CATEGORY_LAUNCHER);
PackageManager manager = getPackageManager();
intent1 = manager.getLaunchIntentForPackage("com.other.externalapp");
startActivity(intent1);
PD: This code works, but it opens a new instance of "com.other.externalapp" and not what I want, it close an internal connection of "externalapp". I want exactly the same effect achieved with switching between applications with the Galaxy tab touch button.
Maybe it's a permission problem, or to be able to run the exact same PID already open.
Thank you very much for your help people. :good:

[Q] Admob event is not firing sometimes, or is firing, but not completely

I use Admob's rewarded video ad. It can be called by button from my game's pause menu and game over screen. So it works almost always in pause menu, and it's worse on game over screen. So, here's the event handler code:
Code:
public void HandleRewardBasedVideoRewarded(object sender, Reward args)
{
this.RequestRewardBasedVideo();
Lives.lives++;
rewardButtonP.interactable = false;
rewardButtonG.interactable = false;
GameObject.Find("banner").GetComponent<AdBanner>().bannerView.Hide();
if (!pauseUI.activeSelf)
respawn.RespawnAction();
}
Bug 1: Button is always non-interactable if ad is not loaded, but sometimes it is interactable, and nothing happens on click. It looks like 1st, 3rd and 4'th lines were not called.
Bug 2: Sometimes respawn.RespawnAction() is not called from game over screen (it must be called only from there). And it is 100% that !pauseUI.activeSelf.
These bugs are seemed to be random.

Why System Displays a Pop-up Window Twice Asking Users to Add the App to Home Screen When Users Return from a Quick App Opened Through a Deep Link?

Symptom​When a user opens a quick app from AppGallery and returns, a pop-up window is displayed only once to ask the user to add the app icon to the home screen. However, the pop-up window will be displayed twice when the user opens the quick app through a deep link and then returns.
Cause Analysis​Based on the analysis of the page code, it is found that the onBackPress function (for listening to the back button) is overridden.
Java:
onBackPress:function(){
this.entryDirect && this.$app.exit()
}
this.entryDirect is carried during deep link redirection.
onBackPress is triggered when a user taps the back button. If value true is returned, the return logic of the app is used; if value false is returned, the default return logic is used. If no value is returned, the default return logic is used.
The system determines that the quick app is opened through a deep link, and this.app.exit() is called to exit the app. In this case, the finish event is triggered. However, value true is not returned in onBackPress. Then, the finish event is triggered based on the default return logic. After Quick App Center detects the finish event, a pop-up window is displayed to instruct the user to add the app icon to the home screen. As a result, the pop-up window is displayed twice.
Solution​Modify code of the onBackPress function. After this.app.exit() is called to exit the app, the default return logic is not used.
Java:
onBackPress:function(){
if(this.entryDirect){
this.$app.exit()
return true
}
}
Suggestions and Summary​When a page needs to use the onBackPress function to process its own logic, true must be returned at the end of the function. Otherwise, the system return logic is used by default after the onBackPress function is processed, which may cause exceptions.
Checkout in forum

Categories

Resources