我目前有一个具有以下intent-filter的Activity类:这会导致我的应用程序出现在图库的Share-Via菜单中。这一切都很好。现在,我实际上不需要让它成为一个Activity,因为它不需要用户交互。相反,我想把它做成一个服务,通过Gallery中的Share-Via菜单以同样的方式启动。所以我将intent-filter移到了“服务”标签内,例如:但是,现在我在Share-Via菜单中看不到该应用程序了!这是为什么?我需要更改什么才能在Share-Via菜单中列出服务? 最佳答案 这是因为当用户点击Share菜单项时,
我正在使用ActionBarSherlock,我想在其中使用MenuItem.SHOW_AS_ACTION_ALWAYS显示一个EditText。它占据条的整个宽度并根据需要显示。但是我在尝试向其添加TextWatcher时遇到了麻烦。因此基于此处接受的答案:http://goo.gl/ite6h我写:EditTextsearch;publicbooleanonCreateOptionsMenu(com.actionbarsherlock.view.Menumenu){menu.add(0,1,1,R.string.inlineSearch).setIcon(R.drawable.ac
我managed让我的耳机按钮在按下时被我的应用程序识别,但其中一个按钮需要调用MyCustomActivity中的方法。问题是onReceive的第一个参数是无法转换为Activity的上下文,因此我不得不将BroadcastReceiver实现为MyCustomActivity中的内部类。到目前为止一切顺利,但如何在list中注册这个内部MediaButtonEventReceiver?对于独立类来说,这很简单:对MyCustomActivity的mReceiver执行相同操作的技巧/语法是什么?privateBroadcastReceivermReceiver=newBroadc
我对这个描述有点困惑:ThecallermaypassanextraEXTRA_OUTPUTtocontrolwherethisimagewillbewritten.IftheEXTRA_OUTPUTisnotpresent,thenasmallsizedimageisreturnedasaBitmapobjectintheextrafield.Thisisusefulforapplicationsthatonlyneedasmallimage.IftheEXTRA_OUTPUTispresent,thenthefull-sizedimagewillbewrittentotheUriv
我有这两个ImageButtonViewredButton和blueButton但在代码中我只使用了一个定义ImageButtonGButton=(ImageButton)findViewById(R.id.blueButton);然后在clickListener中我有这段代码:GButton.setOnClickListener(newImageButton.OnClickListener(){publicvoidonClick(Viewv){switch(v.getId()){case(R.id.blueButton):GButton=(ImageButton)findViewBy
我的应用使用相机拍照并长期使用。Intentintent=newIntent(MediaStore.ACTION_IMAGE_CAPTURE);UriresultUri=null;resultUri=getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,newContentValues());imageCaptureIntent.putExtra(MediaStore.EXTRA_OUTPUT,resultUri);startActivityForResult(imageCaptureInten
我正在学习构建相机应用程序的教程http://developer.android.com/tools/device.html我调用Camera.open()返回null。我已经在list中声明了权限,我在模拟器和xyboard上都试过了,但我仍然得到null。有谁知道任何快速提示?Camerac=null;try{c=Camera.open()}catch(Exeptione){}returnc;请记住,我没有抛出异常,我只是返回NULL。 最佳答案 那是因为it'snotsupposedtothrowanexception.当没有
Hereismyoriginalquestion我已经在那里实现了答案,但问题仍然存在。这里是要点:所以我正在播放来自外部存储(sdcard)的视频,我在播放视频时遇到了问题,这是我的代码:Uriuri=Uri.parse(url);intent=newIntent(Intent.ACTION_VIEW);intent.setDataAndType(uri,"video/*");提示“抱歉,该视频无法播放”,但在图库中,可以播放。我打印了url,这就是我得到的:VideoPlayerurl:file:///mnt/sdcard/foldername/video-2012-12-26-2
作为我的android应用程序开发研究的一部分,我通过访问LED闪光灯开发了一个简单的SOS应用程序。一切正常,LED以1/2秒的间隔闪烁。但是当用户按下手机中的后退按钮时,应用程序会退出,并在1/2秒后出现“崩溃/强制关闭”消息。我是Android开发的新手,我的代码有什么问题?privatebooleanlOn=true;TimermTimer=newTimer();TimerTaskmTimerTask=newTimerTask(){@Overridepublicvoidrun(){if(lOn){finalParametersp=camera.getParameters();L
用户将触摸一个图像,重要的是他的手指是否在该图像中离开我尝试编写一个onTouchListner()然后使用swichcase但我不知道如何继续image.setOnTouchListener(newOnTouchListener(){@OverridepublicbooleanonTouch(Viewarg0,MotionEventevent){switch(event.getAction()){caseMotionEvent.ACTION_UP:break;caseMotionEvent.ACTION_DOWN:break;caseMotionEvent.ACTION_MOVE:b