开发者

set imageView's image to contact photo

开发者 https://www.devze.com 2023-03-13 14:35 出处:网络
Want to set photo from imageView to contact photo. I am trying this,but I get an exception.Here is my code :

Want to set photo from imageView to contact photo. I am trying this,but I get an exception.Here is my code :

        draw.btnSetAs.setOnClickListener(new View.OnClickListener() {

         public void onClick(View v){
            Context context= getApplicationContext();
                            Bitmap icon= BitmapFactory.decodeResource(context.getResources(),
                    R.id.viwer_photo3);
            try {  
                Intent myIntent = new Intent();  
                myIntent.setAction(ContactsContract.Intents.ATTACH_IMAGE);  
                myIntent.putExtra(Intent.EXTRA_STREAM, icon);  
                startActivity(myIntent);  

            } catch (ActivityNotFoundException anfe) {  
                Log.i("ImageContact", 
                        "Firing Intent to set image as contact failed.", anfe);  

            }
        } 
    });

I am getting this exception:

06-16 14:25:34.431: INFO/ImageContact(1708): Firing Intent to set image as contact failed.
06-16 14:25:34.431: INFO/ImageContact(1708): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.contacts.action.ATTACH_IMAGE (has extras) }
06-16 14:25:34.431: INFO/ImageContact(1708):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1567)
06-16 14:25:34.431: INFO/ImageContact(1708):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1537)
06-16 14:25:34.431: INFO/ImageContact(1708):     at android.app.Activity.startActivityForResult(Activity.java:2858)
06-16 14:25:34.431: INFO/ImageContact(1708):     at android.app.Activity.startActivity(Activity.java:2964)
06-16 14:25:34.431: INFO/ImageContact(1708):     at com.aragast.display.FullScreenImageActivity$4.onClick(FullScreenImageActivity.java:143)
06-16 14:25:34.431: INFO/ImageContact(1708):     at android.view.View.performClick(View.java:2408)
06-16 14:25:34.431: INFO/ImageContact(1708):     at android.view.View$PerformClick.run(View.java:8817)
06-16 14:25:34.43开发者_开发技巧1: INFO/ImageContact(1708):     at android.os.Handler.handleCallback(Handler.java:587)
06-16 14:25:34.431: INFO/ImageContact(1708):     at android.os.Handler.dispatchMessage(Handler.java:92)
06-16 14:25:34.431: INFO/ImageContact(1708):     at android.os.Looper.loop(Looper.java:144)
06-16 14:25:34.431: INFO/ImageContact(1708):     at android.app.ActivityThread.main(ActivityThread.java:4937)
06-16 14:25:34.431: INFO/ImageContact(1708):     at java.lang.reflect.Method.invokeNative(Native Method)
06-16 14:25:34.431: INFO/ImageContact(1708):     at java.lang.reflect.Method.invoke(Method.java:521)
06-16 14:25:34.431: INFO/ImageContact(1708):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-16 14:25:34.431: INFO/ImageContact(1708):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)

And I can't understand whats the problem.

Thanks


Do you have permission to change contact information?

 <uses-permission android:name="android.permission.WRITE_CONTACTS" />
0

精彩评论

暂无评论...
验证码 换一张
取 消