public static final String ACTION_MAIN = "android.intent.action.MAIN"; public static final String ACTION_VIEW = "android.intent.action.VIEW"; public static final String ACTION_EDIT = "android.intent.action.EDIT"; public static final String ACTION_CALL = "android.intent.action.CALL"; public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
public Intent(String action); public Intent(String action, Uri uri);
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.crop_image_my.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>
<intent-filter> <action android:name="com.example.crop_image_my.copper" /> <data android:scheme="crop" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter>
private void startMyCropIntent(String path) throws FileNotFoundException {
Intent intent = new Intent("com.example.crop_image_my.copper", Uri.parse("crop://" + path));
startActivityForResult(intent, );
}
if (getIntent().getData() != null) {
imgPath = getIntent().getData().getPath(); // 参见uri的组成形式资料
Log.v("<DBW>", imgPath);
myCropView.setBmpPath(imgPath);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.btn_crop:
Bitmap croppedImage = myCropView.getCroppedImage();
croppedImageView.setImageBitmap(croppedImage);
saveCroppedImage(croppedImage);
// return to the last activity
Log.v("<DBW>", newFilePath);
getIntent().putExtra("newPath", newFilePath);
setResult(, getIntent());
break;
case R.id.btn_cancel:
setResult();
break;
default:
break;
}
finish();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case :
if (resultCode == ) {
String path = data.getExtras().getString("newPath");
Log.v("<DBW>", "get------" + path);
Bitmap bmp = BitmapFactory.decodeFile(path);
iv.setImageBitmap(bmp);
} else if (resultCode == ) {
Toast toast = Toast.makeText(this, "您取消了操作", Toast.LENGTH_LONG);
toast.show();
}
break;
default:
break;
}
}
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity 启动显示的 android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity 切换的 android:name=".ShowMessage" android:label="@string/title_activity_display_message" android:parentActivityName=".MainActivity" > <meta-data android:name="android.support.PARENT_ACTIVITY" android:value="com.example.android_switchactivity.MainActivity" /> </activity> </application>
public final static String EXTRA_MESSAGE = "com.example.android_switchactivity.MESSAGE"; 这个string可以任意赋值,但要保证唯一Intent intent = new Intent(this, ShowMessage.class); EditText mEt = (EditText)findViewById(R.id.edit_message); String message = mEt.getText().toString(); intent.putExtra(EXTRA_MESSAGE, message); startActivity(intent);
Intent intent = getIntent(); String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE); TextView mTv = new TextView(this); mTv.setTextSize(40); mTv.setText(message);
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有