我试图在Android手机上使用本机电子邮件客户端发送电子邮件.
我试过以下方法为邮件添加附件...
方法 - 1
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://sdcard/abc.jpg"));
Run Code Online (Sandbox Code Playgroud)
方法2
将图像作为正文内容发送---
sendIntent.putExtra(Intent.EXTRA_TEXT, "<HTML><BODY><b><IMG**SRC=
\"data:image/jpeg;base64," + <imagepath> + "\"**alt = \"**pleaseview this
image\"/></b></BODY></HTML>");
Run Code Online (Sandbox Code Playgroud)
我可以手动成功附加图像,但当我尝试附加并以编程方式发送它时,邮件是在没有附件的情况下发送的.
如果有办法使用电子邮件客户端以编程方式发送附件,请告诉我
我正在使用ContactsContract api intent来显示活动中的所有联系人.此意图返回联系人的ID.我需要获得此联系人的邮政地址.
这是我用于显示联系人的代码:
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
startActivityForResult(intent, PICK_CONTACT);
我在onActivityResult函数中得到了结果.
请帮忙,我该怎么做.
我想解压缩受密码保护的文件..我知道如何解压缩没有密码保护的普通zip文件.有一些像Winzip这样的应用程序可以做同样的事情.
你们能指点我一些教程或我可以用来实现这个的东西吗?
我想调整原始的View Pager,它会显示下一个孩子的提示..请参阅下图:

我尝试创建自己的ViewPager,扩展了原始的View Pager,但我无法使其工作.
如果你能指出我做这个或类似的任何教程或图书馆,我真的很感激.
谢谢.
我在我的一个活动中使用选项卡视图.我想根据他们的选择更改选项卡的drawable.所以就像这样 - 我有4张图像T11,T12,T21,T22.我想先选择标签1来设置图像T11和T22.现在我想在选择Tab 2后立即将图像更改为T12和T21.
到目前为止,我尝试使用drawable类型的xml文件:
左侧标签可绘制(tab1) -
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
style="?attr/left_active" />
<item android:state_window_focused="false" android:state_enabled="false"
style="?attr/left_inactive" />
<item android:state_pressed="true" android:state_enabled="true"
style="?attr/left_active" />
<item android:state_pressed="true" android:state_enabled="false"
style="?attr/left_inactive" />
</selector>
Run Code Online (Sandbox Code Playgroud)
可选项目标签(Tab2) -
<item android:state_window_focused="false" android:state_enabled="true"
style="?attr/right_active" />
<item android:state_window_focused="false" android:state_enabled="false"
style="?attr/right_inactive" />
<item android:state_pressed="true" android:state_enabled="true"
style="?attr/right_active" />
<item android:state_pressed="true" android:state_enabled="false"
style="?attr/right_inactive" />
Run Code Online (Sandbox Code Playgroud)
在活动中:
TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("Tab1", getResources().getDrawable(R.drawable.left)).setContent(new Intent(this, Left.class)));
tabHost.addTab(tabHost.newTabSpec("tab2")
.setIndicator("Tab2", getResources().getDrawable(R.drawable.right))
.setContent(new Intent(this, Right.class)));
tabHost.setCurrentTab(1);
Run Code Online (Sandbox Code Playgroud)
请帮忙...
我有一个hashmap,我希望得到这个hashmap中的一个键数组,但我希望对数组进行排序.
例如,如果地图如下所示:
<"2",obj1>
<"4",obj2>
<"6",obj3>
<"10",obj4>
<"5",obj5>
<"1",obj6>
<"15",obj7>
<"3",obj8>
Run Code Online (Sandbox Code Playgroud)
我希望数组为:["1","2","3","4","5","6","10","15"]
越快越好.有没有内置的方法来做到这一点?
更新1
当我使用TreeMap时,键按以下顺序排序:
"1","10","2"等.
但我希望它们像:"1","2","3"......"10","15".
我的代码是这样的......
public class MainActivity extends Activity {
String a = new String("1,2,3,4,5")
private Button button1;
private Button button2;
private Button button3;
private Button button4;
private Button button5;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
startBtn = (Button) findViewById(R.id.startBtn);
startBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
String[] splited=a.split(",");
for(String b : splited){
(button"b").setBackground(Color.RED);
//This is the part where I get stucked//
//I know the code is wrong but I just want to express my idea//
}
}
});
} …Run Code Online (Sandbox Code Playgroud) 我从网络服务器(具有透明背景)获取图像.现在我需要将此图像保存在我的SD卡上并显示给用户.但是当我将图像保存到SD卡时...它以黑色背景保存..需要这个图像与背景..
我试过以下方法来保存图像---
方法1:
Bitmap bitmap = BitmapFactory.decodeStream(is);
byte[] b;
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 75, bytes);
b = bytes.toByteArray();
try {
File myFile = new File("/sdcard/" + image_id + ".jpg");
myFile.createNewFile();
OutputStream filoutputStream = new FileOutputStream(myFile);
filoutputStream.write(b);
filoutputStream.flush();
filoutputStream.close();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.d("file", "not created");
}
Run Code Online (Sandbox Code Playgroud)
方法2:
MediaStore.Images.Media.insertImage(getContentResolver(),
bitmap, "sample", "image/png");
Run Code Online (Sandbox Code Playgroud)
请帮忙......
我使用以下代码将文件上传到S3存储桶:
//upload code start
AWSCredentials credential = new BasicAWSCredentials(AppConstants.AWS_ACCESS_KEY_ID, AppConstants.AWS_SECRET_ACCESS_ID);
TransferManager manager = new TransferManager(credential);
// Transfer a file to an S3 bucket.
Upload upload = manager.upload("bucket_name", AppConstants.AWS_ACCESS_KEY_ID, file);
while (!upload.isDone()) {
Thread.sleep(200);
}
//upload code end
Run Code Online (Sandbox Code Playgroud)
我想将它放入我的存储桶中名为"android_uploads"的目录中,但Transfer Manager将所有文件上传到存储桶的根目录.
知道我怎么能做到这一点?