package com.example.justask;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // "com.example.victimapp/.PartOne"
        Intent callIntent = new Intent("com.example.victimapp.intent.action.JUSTASK");
        startActivityForResult(callIntent, 2);
        // Intent resultIntent = new Intent();
        // setResult(Activity.RESULT_OK, resultIntent);

        // String result = callIntent.getDataString();
        // Intent data = new Intent();
        // onActivityResult(0, RESULT_OK, data);
        // Log.d("MOBIOTSEC", "onCreate: " + data.getDataString());

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        Log.d("MOBIOTSEC", "code: "+ resultCode);
        if (requestCode == 2) {
            if (resultCode == RESULT_OK) {

                Log.d("MOBIOTSEC", "res: " + data.getDataString());
                // do your task

            } else if (resultCode == RESULT_CANCELED) {
                // do your task
                Log.d("MOBIOTSEC", "error");
            }
            else
            {
                Log.d("MOBIOTSEC", "error 2");
                Log.d("MOBIOTSEC", "res: " + data.getDataString());
            }
        }

    }
}