안녕하세요 안드로이드 초보개발자입니다.
제가 만든 두 앱이 있는데 한 앱(A)은 edittext에서 작성한 텍스트를 제가만든 다른 앱(B)에 전달하는것이고, B는 A에서 전달받은 데이터를 통해 작업을 수행하는겁니다.
현재 A에서 B로 share를 누르면 넘어가지긴하는데 데이터가 넘어가지 않습니다. 어떻게 해야할까요?
A앱의 xml의 intent-filter부분입니다.
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" />
<data android:mimeType = "text/*"/>
</intent-filter>
A앱의 java 코드입니다.
EditText editText;
Intent sendIntent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText = (EditText) findViewById(R.id.editText);
sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_VIEW);
sendIntent.putExtra("TEXT", editText.getText().toString());
sendIntent.setType("text/*");
}
B앱의 xml의 intent-filter부분입니다.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/*"/>
</intent-filter>
B앱의 intent를 받는부분의 java코드입니다.
Intent receiveIntent = getIntent();
url = receiveIntent.getStringExtra("TEXT");
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
도움을 주시면 감사하겠습니다.
수정 - share라는 버튼은 만든게아니라 꾹누르면 나오는 copy 등과 함께 android에서 제공해주는 버튼을 뜻합니다.