Tag: android intent

如何捕捉图像并将其与原生Android Camera一起存储

我有一个问题捕捉图像,并从本机相机应用程序存储它。 这里是我的一些代码的示例。 _path = Environment.getExternalStorageDirectory() + "make_machine_example.jpg"; File file = new File( _path ); Uri outputFileUri = Uri.fromFile( file ); Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE ); intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri ); startActivityForResult( intent, 0 ); 照片拍完后,我回到我原来的活动,当我通过Android DDMS文件浏览器导航到我的SD卡的图片不存在。 任何人都知道为什么这不被保存?

差异和何时使用getApplication(),getApplicationContext(),getBaseContext()和someClass.this

我是新来的android和我试图了解getApplication() , getApplicationContext( ), getBaseContext() , getContext()和someClass.this ,特别是当在以下代码行中使用这些方法: 当我发起敬酒之间有什么区别,在哪些情况下,我使用它们? Toast.makeText(LoginActivity.this, "LogIn successful", Toast.LENGTH_SHORT).show(); Toast.makeText(getApplication(), "LogIn successful", Toast.LENGTH_SHORT).show(); Toast.makeText(getApplicationContext(), "LogIn successful", Toast.LENGTH_SHORT).show(); Toast.makeText(getBaseContext(), "LogIn successful", Toast.LENGTH_SHORT).show(); 意图相同: Intent intent = new Intent(getApplicationContext(), LoginActivity.class); Intent intent = new Intent(MenuPagina., LoginActivity.class); Intent intent = new Intent(getBaseContext(), LoginActivity.class); Intent intent = new Intent(getApplication(), LoginActivity.class);

检测耳机是否插入Android设备。

如何确定耳机是否插入Android设备?

使用意图将数据从活动传递到服务

如何获取从调用Activity传递的Android服务中的数据?

如何在Android应用程序中点击button打开第二个活动

我正在学习构buildAndroid应用程序,我需要一些特定的帮助。 我似乎无法摆脱我需要改变哪些模板代码位,哪些位是静态的。 在LAYOUT文件夹中,我有我的ACTIVITY_MAIN.XML读取 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <Button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/main_buttons_photos" /> </LinearLayout> 接下来,我有第二个活动ACTIVITY_SEND_PHOTOS.XML <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="@string/hello_world" tools:context=".SendPhotos" /> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:text="@string/title_activity_send_photos" android:textAppearance="?android:attr/textAppearanceLarge" /> </RelativeLayout> 然后我有我的MainActivity.java (这是.class?)它读取包com.example.assent.bc; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; […]

音量变化是否有播放动作?

我正在编程一个小部件,每当用户更改铃声音量或振动设置时都需要更新。 捕获android.media.VIBRATE_SETTING_CHANGED对于振动设置工作得很好,但是我还没有find任何方式在振铃音量发生变化时得到通知,尽pipe当用户按下音量增大/减小的物理键时我可以尝试捕获,还有许多其他的选项可以在不使用这些键的情况下改变音量。 你知道是否有任何广播行动或任何方式来创build一个或没有它的解决问题?

如何发送HTML电子邮件

我发现了一种使用intent发送纯文本电子邮件的方法: final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"example@mail.com"}); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Test"); 但是我需要发送HTML格式的文本。 尝试setType(“文本/ HTML”)不起作用。

检测呼出是否已被应答

一旦广播了ACTION_NEW_OUTGOING_CALL ,我需要捕获对方答案的以下事件。 你能build议如何达到这个目的吗? 我知道这是可能的android拨号器应用程序更改绿色的android图标激动人心的时候,他们拿起。 谢谢! 更新:我已经看了Android的应用程序来源处理传出的电话。 我注意到ContactsUtils的以下方法: /** * Kick off an intent to initiate a call. */ public static void initiateCall(Context context, CharSequence phoneNumber) { Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED, Uri.fromParts("tel", phoneNumber.toString(), null)); context.startActivity(intent); } 我想我的答案是在侦听Intent.ACTION_CALL_PRIVILEGED的活动中。 所以重新我的问题:有谁知道哪个活动处理Intent.ACTION_CALL_PRIVILEGED ? 先进的谢谢你

Google In-App结算,IllegalArgumentException:在升级到Android L Dev Preview之后,Service Intent必须是显式的

我的应用内结算代码工作正常,直到我升级到Android L Dev Preview。 现在我的应用程序启动时出现此错误。 有谁知道什么改变了L导致这个或我应该如何改变我的代码来解决这个问题? android { compileSdkVersion 'android-L' buildToolsVersion '20' defaultConfig { minSdkVersion 13 targetSdkVersion 'L' … … compile 'com.google.android.gms:play-services:5.+' compile 'com.android.support:support-v13:21.+' compile 'com.android.support:appcompat-v7:21.+' … … 应用程序启动时的错误: 06-29 16:22:33.281 5719-5719/com.tbse.wnswfree D/AndroidRuntime﹕ Shutting down VM 06-29 16:22:33.284 5719-5719/com.tbse.wnswfree E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.tbse.wnswfree, PID: 5719 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tbse.wnswfree/com.tbse.wnswfree.InfoPanel}: java.lang.IllegalArgumentException: Service […]

用Phonegap创build一个Android服务? (即使在closures的情况下也可以运行phonegap应用

我一直在使用Phonegap开发一个Android应用程序,现在想在应用程序closures的时候这样做,它仍然可以在应用程序中执行java / js代码。 所以我明白我需要创build一个服务。 如果我在phonegap上创build一个服务插件,我仍然可以执行JavaScript代码或只有Java? 有没有人做这样的事情? 我发现这个讨论,但似乎没有工作: http : //groups.google.com/group/phonegap/browse_thread/thread/722b0e796baa7fc6这就是我现在所拥有的。 如果我不能想象出来,我会转而开发原生的,我会问,如果有人曾经这样做过。 我似乎无法find任何类似的phonegap插件。 编辑:我有一个执行Java代码作为服务的应用程序。 但是,当它调用sendjavascript不起作用。 那么有没有办法让JavaScript代码在后台运行,当一个应用程序closures与phonegap? 谢谢