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;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    // FLAG 1:
    // FLAG 2: lapidem_non_vi
    // FLAG 3:
    // FLAG 4:

    @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, 0);

        // 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 == 0) {
            if (resultCode == RESULT_OK) {

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

            } else if (resultCode == RESULT_CANCELED) {
                // do your task
                Log.d("MOBIOTSEC", "error");
            }
            else
            {
                Bundle extra = data.getExtras();

                /*for (String key: extra.keySet())
                {
                    Log.d ("MOBIOTSEC", key + " is a key in the bundle");
                }*/

                Log.d("MOBIOTSEC", "Last");
                Log.d("MOBIOTSEC", "res: " + extra.getString("flag"));
            }
        }

    }
}