标签: android-intent

针对特定文件扩展名的Android意图过滤器?

我希望能够从'net下载具有特定扩展名的文件,并将其传递给我的应用程序来处理它,但我无法找出intent过滤器.文件类型不包含在mimetypes中,我尝试使用

<data android:path="*.ext" />
Run Code Online (Sandbox Code Playgroud)

但我无法让它发挥作用.

android android-manifest android-intent

88
推荐指数
8
解决办法
7万
查看次数

弹出软键盘时页面滚动

我有一个<ScrollView>布局:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/my_scrollview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <EditText
            android:id="@+id/input_one"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:inputType="number" >

         <EditText
            android:id="@+id/input_two"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:inputType="number" >

         <EditText
            android:id="@+id/input_three"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:inputType="number" >

          <Button
            android:id="@+id/ok_btn"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="20dp"
            android:text="@string/ok_str" />

      </LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

如上所示,简单布局包含三个输入字段和一个"确定"按钮.

我使用上面的布局运行我的应用程序,当我点击第一个输入字段(@+id/input_one)时,软键盘将从屏幕底部弹出,它隐藏第三个输入字段和"确定"按钮.

自从我使用以来<ScrollView>,我想我可以向上滚动页面以查看第三个输入字段和软键盘隐藏的"确定"按钮,但页面不可滚动.为什么?如何摆脱它?基本上,我想看到每个输入字段和"确定"按钮,甚至软键盘弹出.

android android-keypad android-intent android-layout android-scrollview

88
推荐指数
7
解决办法
11万
查看次数

如何传递包含对象列表的parcelable对象?

我在Parcelable下面创建了一个对象,我的对象包含一个ListProducts.在我的构造函数中,如何处理重新创建我ParcelableList

我检查了包裹中可用的所有方法,所有可用的方法都是readArrayList(ClassLoader).我不确定这是不是最好的方法,你的建议真的很值得赞赏.

public class Outfits implements Parcelable {

    private String url;
    private String name;
    private List<Product> products;

    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public List<Product> getProducts() {
        return products;
    }
    public void setProducts(List<Product> products) {
        this.products = products;
    }

    public void writeToParcel(Parcel dest, int …
Run Code Online (Sandbox Code Playgroud)

android android-intent android-activity

87
推荐指数
4
解决办法
7万
查看次数

Intent.EXTRA_EMAIL未填充"收件人"字段

我试图使用从我的应用程序发送电子邮件,但电子邮件的收件人字段将不会填充.如果我添加代码来填写主题或文本,它们工作正常.只有To字段不会填充.

我也尝试将类型更改为"text/plain"和"text/html",但我遇到了同样的问题.有人可以帮忙吗?

public void Email(){

    Intent emailIntent = new Intent(Intent.ACTION_SEND); 
    emailIntent.setType("message/rfc822");  //set the email recipient
    String recipient = getString(R.string.IntegralEmailAddress);
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL  , recipient);
    //let the user choose what email client to use
    startActivity(Intent.createChooser(emailIntent, "Send mail using...")); }
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用的电子邮件客户端是Gmail

android android-intent

87
推荐指数
2
解决办法
3万
查看次数

如何在Android应用程序中单击按钮打开第二个活动

我正在学习构建Android应用程序,我需要一些特定的帮助.我似乎无法理解我需要更改哪些模板代码,以及哪些位是静态的.

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>
Run Code Online (Sandbox Code Playgroud)

接下来,我有我的第二个活动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>
Run Code Online (Sandbox Code Playgroud)

然后我有我的MainActivity.java(这是.class?)这个包com.example.assent.bc;

 import android.os.Bundle;
 import android.app.Activity;
 import android.view.Menu;
 import android.view.View;

 public class MainActivity extends Activity {

 @Override
 public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_main);
 }

 @Override
 public boolean onCreateOptionsMenu(Menu …
Run Code Online (Sandbox Code Playgroud)

android android-intent android-activity

87
推荐指数
5
解决办法
31万
查看次数

getParcelableExtra 方法已弃用

我将Parcelable数据传递到Intent中,并使用getParcelableExtra(name:)方法将其从另一端取出。然而,getParcelableExtra(name:)似乎已被弃用。如何修复弃用警告?或者,还有其他选择吗?我使用compileSdkVersion的值为 33。

代码片段

var data = intent.getParcelableExtra("data")
Run Code Online (Sandbox Code Playgroud)

android parcelable android-intent

87
推荐指数
5
解决办法
6万
查看次数

什么是粘性广播?

我在android文档中遇到了这个术语,附带定义

这些是广播,其数据在完成后由系统保存,因此客户端可以快速检索该数据而无需等待下一次广播.

这是什么意思?有人可以用特定的例子详细说明它的用法吗?我相信我们必须要求获得使用此意图的许可吗?为什么这样?

<uses-permission android:name="android.permission.BROADCAST_STICKY"/> - Allows an application to broadcast sticky intents.
Run Code Online (Sandbox Code Playgroud)

android android-intent

86
推荐指数
3
解决办法
10万
查看次数

通过Android上的Intent选择任何类型的文件

我想为可以返回任何类型文件的应用启动intentchooser

目前我使用(我从Android电子邮件源代码中复制了文件附件)

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
Intent i = Intent.createChooser(intent, "File");
startActivityForResult(i, CHOOSE_FILE_REQUESTCODE);
Run Code Online (Sandbox Code Playgroud)

但它只在我的Galaxy S2上显示"画廊"和"音乐播放器".此设备上有一个文件浏览器,我希望它出现在列表中.我还希望相机应用程序显示在列表中,以便用户可以拍摄照片并通过我的应用程序发送.如果我安装Astro文件管理器,它也会响应这个意图.我的客户只是Galaxy SII所有者,我不想强​​迫他们安装Astro文件管理器,因为他们已经拥有一个基本但足够的文件管理器.

知道如何实现这一目标吗?我很确定我已经看到默认文件管理器出现在这样的菜单中以选择文件,但我不记得在哪个应用程序中.

android file intentfilter android-intent

85
推荐指数
4
解决办法
10万
查看次数

检查是否安装了应用程序 - Android

我正在尝试从Google Play安装应用.我可以理解,在打开Goog​​le Play商店网址时,它会打开Goog​​le Play,当我按下后退按钮时,活动会恢复.

Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(appURL));
marketIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(marketIntent);
Run Code Online (Sandbox Code Playgroud)

当我回到活动时,我试着调用它onResume()来检查应用程序是否已安装,但是我收到错误:

@Override
protected void onResume() {
    super.onResume();
    boolean installed = false;
    while (!installed) {
        installed  =   appInstalledOrNot(APPPACKAGE);
        if (installed) {
             Toast.makeText(this, "App installed", Toast.LENGTH_SHORT).show();
        }
    }
}

private boolean appInstalledOrNot(String uri) {
  PackageManager pm = getPackageManager();
  boolean app_installed = false;
  try {
      pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
      app_installed = true;
  }
  catch (PackageManager.NameNotFoundException e) {
      app_installed = false;
  }
  return app_installed ;
}
Run Code Online (Sandbox Code Playgroud)

错误如下:

E/AndroidRuntime(796):java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.appinstaller/com.example.appinstaller.MainActivity}:android.content.ActivityNotFoundException:找不到处理Intent的活动{act = …

android android-intent google-play

84
推荐指数
5
解决办法
10万
查看次数

如何在Activity转换上执行淡入淡出动画?

我正在编写我的徽标活动和我的主要活动之间的过渡效果,但我有一个问题,即在消失之前,活动转移到顶部:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false" >

    <alpha
        android:duration="2000"
        android:fromAlpha="0.0"
        android:toAlpha="1.0" >
    </alpha>

</set>
Run Code Online (Sandbox Code Playgroud)

我怎么能改进这个代码才能获得消失效果呢?

animation android android-intent pending-transition

82
推荐指数
4
解决办法
9万
查看次数