2014-09-15 1 views
0

나는 안드로이드 프로그래밍에 대해 하나의 질문이 있습니다. 파일 탐색기 응용 프로그램이 있고 열린 사진 음악 등 다양한 기능을 구현하고 싶습니다. 그러나 응용 프로그램 자체에서는 다른 응용 프로그램에 의도를 보내지 않습니다! 그래서, 내 질문은, 어떤 의도 필터는 "열기"의도를 받기위한 "플러그인"응용 프로그램에 사용해야합니까? 의도를 수신하기위한 의도 필터

public static void openFile(final Context context, final File target) { 
    final String mime = MimeTypes.getMimeType(target); 
    final Intent i = new Intent(Intent.ACTION_VIEW); 

    if (mime != null) { 
     i.setDataAndType(Uri.fromFile(target), mime); 
    } else { 
     i.setDataAndType(Uri.fromFile(target), "*/*"); 
    } 

    if (context.getPackageManager().queryIntentActivities(i, 0).isEmpty()) { 
     Toast.makeText(context, R.string.cantopenfile, Toast.LENGTH_SHORT) 
       .show(); 
     return; 
    } 

    try { 
     context.startActivity(i); 
    } catch (Exception e) { 
     Toast.makeText(context, 
       context.getString(R.string.cantopenfile) + e.getMessage(), 
       Toast.LENGTH_SHORT).show(); 
    } 
} 

답변

0

확인 후, 당신은 단순히 활동 내부 및 호출에서 이미지 뷰어를 구현의이 새로운 활동을 만들 자신 탐색기 에서 이미지를 엽니의이 ImageActivity 가정 해 봅시다한다고 가정하자 내 코드입니다 활동은 단순히

편집

에게 이미지 바이트 SENDING 활동을 포함하는 추가 번들과 의도를 보내

Intent intent = new Intent(MainActivity.this, ImageActivity.class); 
      ImageView imageView = findViewById(R.id.image).getDrawable(); 
    imageView.buildDrawingCache(); 
    Bitmap image = imageView.getDrawingCache(); 
    Bundle extras = new Bundle(); 
    extras.putParcelable("imagebitmap", image); 
    intent.putExtras(extras); 
    startActivity(intent); 

활동 ImageActivity

Bundle extras = getIntent().getExtras(); 
Bitmap bmp = (Bitmap) extras.getParcelable("imagebitmap"); 
       ImageView image = findViewById(R.id.image); 
image.setImageBitmap(bmp); 
+0

그래 받기,하지만 난 그 ImageActivity에서 무엇을 작성해야? 몇 가지 코드를 작성하십시오. – Trabefi

+0

답변으로 편집 됨 –

+0

좋아요, 시도해보십시오. :) – Trabefi

관련 문제