0

I have a java example code that demonstrate how to implement a call to another app. My app is a Qt app so I don't know how to implement that. This is the java code that I received:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        button = (Button) findViewById(R.id.button);;
        
        if(getIntent() != null)
            //do something with received intent
            ...

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Uri.Builder builder = new Uri.Builder();
                builder.scheme("demo")
                       .authority("demoresult");

                String uriResponse = builder.build().toString();

                builder = new Uri.Builder();
                builder.scheme("myapp")
                        .authority("action")
                        .appendQueryParameter("caller", BuildConfig.APPLICATION_ID)
                        .appendQueryParameter("type", "readNumber")
                        .appendQueryParameter("responseUri", uriResponse)

                Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(intent);
            }
        });
    }
}
            

I've tried to do that in java but the app crashes because it tells me I am running an activity on another thread. How can I do something like in the example (starting an Activity and get the result on the onCreate function)?

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
Fausto01
  • 171
  • 14
  • I see nothing what would let your app crash. Please post lines from Logcat. Further: what result do you expect from ACTION_VIEW? I can not follow you. – blackapps Sep 24 '21 at 14:35
  • My question is, how do I implement this example in a Qt application? – Fausto01 Sep 25 '21 at 15:20
  • `(starting an Activity and get the result on the onCreate function)?` In that code no activity is started and no result is received in onCreate(). I can not follow you. – blackapps Sep 25 '21 at 15:30
  • startActivity(intent); activity is started in the onClick() listener. The example is doing something with the intent result on the first lines of onCreate(). – Fausto01 Sep 26 '21 at 12:59
  • Yes it starts action view. But not an activity. – blackapps Sep 26 '21 at 13:53
  • Ok, this action is starting an external app that read cards. The result of this app(the pan number of the card read) is managed in the onCreate() of the class TestActivity, but I don't know where is the link between these two apps. The only thing I found is in AndroidManifest.xml – Fausto01 Sep 26 '21 at 14:34

0 Answers0