GVKun编程网logo

Android:ACTION_SEND_MULTIPLE与com.android.email

15

本文将为您提供关于Android:ACTION_SEND_MULTIPLE与com.android.email的详细介绍,同时,我们还将为您提供关于AndroidACTION_SEND事件:“消息无法

本文将为您提供关于Android:ACTION_SEND_MULTIPLE与com.android.email的详细介绍,同时,我们还将为您提供关于Android ACTION_SEND事件:“消息无法上传附件”、Android Emulator 是否包含 Android SDK 或 Android Studio?、android intent action_send选项只有一次、Android log cat显示android.content.pm.PackageManager $NameNotFoundException:应用程序包com.google.android.ba的实用信息。

本文目录一览:

Android:ACTION_SEND_MULTIPLE与com.android.email

Android:ACTION_SEND_MULTIPLE与com.android.email

我正在尝试将Intent中的多个附件发送到电子邮件应用(而不是Gmail应用).我正在使用:

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "sample@email.com" });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"This is an email");
emailIntent.putExtra(Intent.EXTRA_TEXT, "This is the body");

File f1 = null;
File f2 = null;
try {
    f1 = new File("/sdcard/test");
    f2 = new File("/sdcard/test.1");
    FileWriter fw1 = new FileWriter(f1);
    FileWriter fw2 = new FileWriter(f2);
    fw1.write("this is some text");
    fw2.write("this is more text");
    fw1.close();
    fw2.close();
} catch (IOException e) {
    e.printstacktrace();
}

ArrayList<Uri> uris = new ArrayList<Uri>();
uris.add(Uri.fromFile(f1));
uris.add(Uri.fromFile(f2));
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,uris);

startActivity(emailIntent);

当Gmail用于处理Intent时,它会显示两个附件,并且一切正常.使用电子邮件应用程序时,不会添加任何附件.在EXTRA_STREAM中使用单个Uri时,单个附件可以工作,但使用ArrayList则不行.我把这个代码拼凑在这里提出的其他问题中,但没有一个能解决这个问题.有人可以帮忙吗?

解决方法:

使用

emailIntent.setType(" */ * ");

没有空格

see here ACTION_SEND_MULTIPLE

Android ACTION_SEND事件:“消息无法上传附件”

Android ACTION_SEND事件:“消息无法上传附件”

我正在尝试实现一个共享按钮,用于捕获屏幕截图并通过标准Android界面共享.我能够创建屏幕截图(我可以在浏览SD卡时看到它),但是当我尝试发送它时,消息应用程序会出错:“消息无法上传附件.”

我的代码

File imageDir = new File(Environment.getExternalStorageDirectory(), "inPin");
if(!imageDir.exists()) { imageDir.mkdirs(); }
File closeupImageFile = new File(imageDir, "closeup.png");
File overviewImageFile = new File(imageDir, "overview.png");

View mapView = findViewById(R.id.floor_map);
saveScreenshottoFile(mapView, closeupImageFile);

ArrayList<Uri> imageUris = new ArrayList<Uri>();
imageUris.add(Uri.fromFile(closeupImageFile));

String message = String.format("I'm on %s %s", building.name, getCurrentFloor().name);

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, message);
sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
sendIntent.setType("image/*");
startActivity(Intent.createChooser(sendIntent, "Share via"));

saveScreenshottoFile方法

private static void saveScreenshottoFile(View view, File saveFile) throws IOException {
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache(true);
    Bitmap bitmap = view.getDrawingCache();
    FileOutputStream out = new FileOutputStream(saveFile);
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
    out.close();
}

我在模拟器上使用Android Marshmallow,API级别23 – 我不知道这是否有所作为,但我能够在模拟器上使用其他应用程序共享它并且工作正常.

解决方法:

您正在发送文件URI,其中Intent.FLAG_GRANT_READ_URI_PERMISSION不适用,不应使用,如this video及其accompanying blog post中所述.其他应用程序需要存储权限才能访问您的文件.

来自博文:

Instead, you can use URI permissions to grant other apps access to specific Uris. While URI permissions don’t work on file:// URIs as is generated by Uri.fromFile(), they do work on Uris associated with 07002. Rather than implement your own just for this, you can and should use 07003 as explained in the 07004.

Android Emulator 是否包含 Android SDK 或 Android Studio?

Android Emulator 是否包含 Android SDK 或 Android Studio?

来自Android Emulator release notes

Android 模拟器包含在 Android Studio 中。

25.3.0 之前的模拟器版本作为 Android SDK 工具。

为确保您拥有最新版本,请检查 SDK Manager 更新。

对于 25.3.0 之前的 Android Emulator 版本,请参阅 Android SDK 工具发行说明。

android intent action_send选项只有一次

android intent action_send选项只有一次

嗨有一个带有此代码的 java来创建共享意图
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT,"text" );
sendIntent.putExtra(Intent.EXTRA_SUBJECT,"subject" );
sendIntent.setType("text/plain");

它现在会创建一个可用应用程序的弹出窗口,并询问您是否要始终使用所选应用程序,或者仅仅一次是否有设置将其置于一次并删除此2个按钮?

像Intent.setoption(‘只需一次’)在android中有这样的选项吗?

谢谢

解决方法

使用
Intent sharingIntent = new Intent ( android.content.Intent.ACTION_SEND );
sharingIntent.setType ( "text/plain" );
sharingIntent.putExtra ( android.content.Intent.EXTRA_TEXT,body.toString () );
startActivity(Intent.createChooser(sharingIntent,"Share using?"));

代替

startActivity(sharingIntent);

Android log cat显示android.content.pm.PackageManager $NameNotFoundException:应用程序包com.google.android.ba

Android log cat显示android.content.pm.PackageManager $NameNotFoundException:应用程序包com.google.android.ba

我是一个更新鲜的android,当我尝试在avd中运行我的应用程序时,在日志猫中发现以下异常,显示不幸的是我的应用程序无法运行,请帮助

 android.content.pm.PackageManager$NameNotFoundException: Application package com.google.android.backup not found
        at android.app.ContextImpl.createPackageContextAsUser(ContextImpl.java:2172)
        at android.app.ContextImpl.createPackageContext(ContextImpl.java:2148)
        at android.content.Contextwrapper.createPackageContext(Contextwrapper.java:671)
        at com.google.android.gms.backup.an.<init>(SourceFile:47)
        at com.google.android.gms.backup.BackupTransportMigratorService.f(SourceFile:248)
        at com.google.android.gms.backup.BackupTransportMigratorService.b(SourceFile:196)
        at com.google.android.gms.backup.BackupTransportMigratorService.onHandleIntent(SourceFile:131)
        at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)

我的android清单如下所示

         <?xml version="1.0" encoding="utf-8"?>
           <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cornex.criminalintent" >

<application
    android:allowBackup="true"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity android:name=".CrimeListActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <activity
        android:name=".CrimePagerActivity"
        android:label="@string/app_name" >

    </activity>
</application>

解决方法:

要创建数据备份应用程序,您需要使用Google备份服务注册您的应用程序.这已在示例中解释.注册后,您必须在AndroidManifest.XML中指定其密钥

 <application
   android:allowBackup="true"
   android:backupAgent="YOUR_BACKUP_AGENT">

   <Meta-data 
      android:name="com.google.android.backup.api_key"
      android:value="YOUR_API_KEY" />
</application>

Android提供BackUpAgentHelper类来处理数据备份的所有操作.要使用此类,您必须使用它扩展您的类.其语法如下:相应的备份代理可以实现,如下面的清单所示.

import android.app.backup.BackupAgentHelper;

public class YOUR_BACKUP_AGENT extends BackupAgentHelper {    

} 

要备份的持久性数据是两种形式之一.它可以是SharedPrefrences,也可以是File. Android在SharedPreferencesBackupHelper和FileBackupHelper各自的类中支持两种类型的备份.

要使用SharedPerefernceBackupHelper,您需要使用sharedPerefernces文件的名称实例化其对象.其语法如下 –

static final String File_Name_Of_Prefrences = "myPrefrences";
SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, File_Name_Of_Prefrences);

您需要做的最后一件事是通过指定备份密钥字符串和帮助程序对象来调用addHelper方法.其语法如下 –

addHelper(PREFS_BACKUP_KEY, helper);

addHelper方法将自动向给定数据子集添加帮助程序到代理程序的配置.

有关详细信息,请参阅this Tutorial和this article

我们今天的关于Android:ACTION_SEND_MULTIPLE与com.android.email的分享就到这里,谢谢您的阅读,如果想了解更多关于Android ACTION_SEND事件:“消息无法上传附件”、Android Emulator 是否包含 Android SDK 或 Android Studio?、android intent action_send选项只有一次、Android log cat显示android.content.pm.PackageManager $NameNotFoundException:应用程序包com.google.android.ba的相关信息,可以在本站进行搜索。

本文标签: