1

I have a soft-keyboard that dose not expands activity it has one button when I click on that I intent another app perfectly but when I want to get respond from that app which extends activity and has a button, the problem is that when I click that button it gets back to my first app but my first app could not get-intent from that. here is my some part of my soft-keyboard:

  public void onKey(int primaryCode, int[] keyCodes) {
   if (primaryCode == LatinKeyboardView.KEYCODE_11) // username_paste_button
    {
        handle_username_paste(); // handle username_paste_button
    }

}
private void handle_username_paste() { // handle username_paste_button
   try {
               // url = (EditText) findViewById(R.id.urlTextEdit);
                String text ="google.com";
                Intent i = new Intent(Intent.ACTION_MAIN);
                PackageManager manager = getPackageManager();
                i = manager.getLaunchIntentForPackage("fake.domain.examplesta");
                i.putExtra("URL", text);
                i.addCategory(Intent.CATEGORY_LAUNCHER);
                startActivity(i);
               // startActivityForResult(i, 1);
            } catch (Exception e) {
                e.printStackTrace();
                //Toast.makeText(v.getContext(), "App Not Found", Toast.LENGTH_LONG).show();
            }
    String name = getIntent().getStringExtra("OTP");
}

have any idea how can I solve this?

David Wasser
  • 93,459
  • 16
  • 209
  • 274
Sparks Sh
  • 109
  • 1
  • 12

1 Answers1

1

Usually you would call startActivityForResult(i, 1) to start an activity and when you are done with that activity you call:

setResult(RESULT_OK) finish()

Now the thing is, in order to receive the results you need the method startActivityForResult() which is only available from a class which extends the Activity class. You have not given much information as to what the 'soft-keyboard' class is doing or used exactly, but the only advice I can give is to restructure your class to be driven from Activities.

Ivan Leong
  • 118
  • 2
  • 10