Created
August 6, 2018 14:49
-
-
Save prabakarviji/7b7ba7ceeb8b5356341cf294051617d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.facebook.react.bridge.ReactContextBaseJavaModule; | |
import com.facebook.react.bridge.ReactApplicationContext; | |
import com.facebook.react.bridge.Promise; | |
import com.facebook.react.bridge.ReactMethod; | |
import com.facebook.react.bridge.WritableMap; | |
import com.facebook.react.bridge.Arguments; | |
import android.app.Activity; | |
import android.content.Intent; | |
import android.net.Uri; | |
import android.graphics.Bitmap; | |
import java.io.InputStream; | |
import android.util.Log; | |
public class ReceiverModule extends ReactContextBaseJavaModule { | |
public ReceiverModule(ReactApplicationContext reactContext) { | |
super(reactContext); | |
} | |
@Override | |
public String getName() { | |
return "Receiver"; | |
} | |
@ReactMethod | |
public void close() { | |
Activity activity = getCurrentActivity(); | |
Intent intent = new Intent(); | |
intent.putExtra("outGoinData", "newData"); | |
activity.setResult(Activity.RESULT_OK, intent); | |
Log.d("Activity", "Result" + Activity.RESULT_OK); | |
activity.finish(); | |
} | |
@ReactMethod | |
public void data(Promise promise) { | |
promise.resolve(processIntent()); | |
} | |
public WritableMap processIntent() { | |
WritableMap map = Arguments.createMap(); | |
String data = ""; | |
Activity currentActivity = getCurrentActivity(); | |
if (currentActivity != null) { | |
Intent intent = currentActivity.getIntent(); | |
data = intent.getStringExtra("externalData"); | |
Log.d("incomingData", data); | |
} else { | |
data = ""; | |
} | |
map.putString("data", data); | |
return map; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment