안드로이드 실전: 그림 공유 메뉴를 지정한 프로그램에 추가하는 방법

1132 단어
           ,           ,     。        :

첫째, 안드로이드 매니페스트에서.xml에서 대응하는 activity에 intent-filter를 추가합니다. 다음과 같습니다.
	
        	
                
                
                
            
        

onResume에서는 intent를 통해 URI를 얻어 Image를 구성합니다.
void initSharedImage(){
		try {			
		    Intent intent = getIntent();
		    InputStream is;
		    Uri imgUri = (Uri)intent.getExtras().getParcelable(Intent.EXTRA_STREAM);		    
			is = getContentResolver().openInputStream(imgUri);
			BufferedInputStream bis = new BufferedInputStream(is);
			Bitmap bm = BitmapFactory.decodeStream(bis);			
			imageview.setImageBitmap(bm);
		} catch (Exception e) {
			Log.e(TAG, "fail to get image from shared", e);
		}
	}

프로젝트 파일:http://download.csdn.net/detail/gdp2852/3809382

좋은 웹페이지 즐겨찾기