-1
我有一個活動,我用它調用Intent從圖庫中選擇圖像。 選擇圖像後,直接返回到主屏幕,畫廊意圖試圖回到我認爲沒有找到的活動。調用OnStartActivityResult後應用程序不會返回
public void startScan(View view) {
Intent intent = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONT ENT_URI);
startActivityForResult(intent, 99);
}
Mainfest:
<application
tools:replace="android:icon,android:theme"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:persistent="true"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="מערכת דיווחים"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustResize|stateAlwaysVisible|stateVisible|adjust Pan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LoginActivity"
android:windowSoftInputMode="adjustResize|stateAlwaysVisible|stateVisible|adjust Pan" >
</activity>
</application>
OnActivityResult:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 99 && resultCode == Activity.RESULT_OK) {
Uri uri = data.getExtras().getParcelable(ScanConstants.SCANNED_RESULT);
Bitmap bitmap = null;
try {
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
getContentResolver().delete(uri, null, null);
pushbutton.setText(bitmap.getByteCount());
} catch (IOException e) {
e.printStackTrace();
}
}
}
你的其他活動的郵政編碼,你如何設置並傳回數據 – Ak9637
在其他活動呼叫某處...意向i =新意圖(); setResult(Activity.RESULT_OK,i);或者你可以發送setResult(Activity.RESULT_CANCEL,resultIntent); –
http://www.javatpoint.com/android-startactivityforresult-example –