如何从下拉菜单中获取值并在要发送的新消息正文中使用它们。
以下是我的代码,
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
// On selecting a spinner item
String label = parent.getItemAtPosition(position).toString();
// Showing selected spinner item
Toast.makeText(parent.getContext(), "You selected: " + label,
Toast.LENGTH_LONG).show();
}
String phoneNo = editPhoneNum.getText().toString();
String sms = editSMS.getText().toString();
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, sms, null, null);
Toast.makeText(getApplicationContext(), "SMS Sent!",Toast.LENGTH_LONG).show();
}
Run Code Online (Sandbox Code Playgroud) 我想用Kakao集成构建一个android应用程序.我的应用需要这些功能.
使用Kakaotalk帐户登录.
获取用户的朋友列表.
可以向用户发布消息(在步骤2中获取).
kakao也提供像facebook sdk这样的api或sdk.我们是否可以在我们自己的应用程序中实现功能而无需启动Kakaotalk应用程序并使用intent向其发送数据?
我有一个图像的MediaStore.Images.Media.DATA uri如何使用该uri获取MediaStore.Images.ImageColumns.ORIENTATION?我得到一个NullPointerException.
以下是我的代码,
private int getOrientation(Context context, Uri photoUri) {
Log.v("orientatioon", "not crashed01");
Cursor cursor = context.getContentResolver().query(photoUri,
new String[] { MediaStore.Images.ImageColumns._ID,MediaStore.Images.ImageColumns.ORIENTATION }, null, null, null);
Log.v("orientatioon", "not crashed02");
cursor.moveToFirst();
Log.v("orientatioon", "not crashed 03");
int i=cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.ORIENTATION));
Log.v("orientatioon", ""+i);
cursor.close();
return i;
}
Run Code Online (Sandbox Code Playgroud)
我得到一个NullPointerException在cursor.moveToFirst()代码行.
我有ImageView,我想分享它的图像.
以下是我的代码,
btshare.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
View content = findViewById(R.id.full_image_view);
content.setDrawingCacheEnabled(true);
Bitmap bitmap = content.getDrawingCache();
File root = Environment.getExternalStorageDirectory();
File cachePath = new File(root.getAbsolutePath() + "/DCIM/Camera/image.jpg");
try
{
root.createNewFile();
FileOutputStream ostream = new FileOutputStream(root);
bitmap.compress(CompressFormat.JPEG, 100, ostream);
ostream.close();
}
catch (Exception e)
{
e.printStackTrace();
}
Intent shareIntent = new Intent(Intent.ACTION_SEND);
Uri phototUri = Uri.parse("/DCIM/Camera/image.jpg");
shareIntent.setData(phototUri);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, phototUri);
startActivity(Intent.createChooser(shareIntent, "Share Via"));
}
});
Run Code Online (Sandbox Code Playgroud)
当我按下按钮我得到这些错误?
01-13 06:00:19.282: W/System.err(6199): java.io.FileNotFoundException: /storage/emulated/0: open failed: EISDIR (Is a directory) …Run Code Online (Sandbox Code Playgroud)