- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
你好 friend ....
我目前正在尝试使用隐式 Intent 制作一个对话框,我想在其中显示我的对话框,如 whatsApp(个人资料照片屏幕),并且在此屏幕中 whatsApp 使用名为“删除照片”的额外字段。当我尝试制作相同类型的屏幕对话框时,我无法添加这个额外的字段(“删除照片”)。我已经完成了所有代码。它在对话框中的三个选项(画廊、照片、相机)中工作正常,我无法在 onActivityResult() 中处理所有这些。我正在发送我所有的源代码,我已经很努力地尝试了,但是我找不到这样做的解决方案。 plz ..... friend 帮我解决这个问题。
在这段代码中,我只是创建了一个名为 openFileChooser() 的方法,我在其中编写了用于创建对话框屏幕的所有代码,并在 onActivityResult() 中处理此结果
这是我的代码
ProfilePhotoActivity.java
public class ProfilePhotoActivity extends Activity implements OnClickListener{
ImageButton back, editPhoto, selectAction;
ImageView imgCamera;
private static final int FILECHOOSER_RESULTCODE = 2888;
protected static final int CAMERA_REQUEST = 0;
protected static final int GALLERY_PICTURE = 1;
private Uri mCapturedImageURI = null;
Intent intent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_profilephoto);
back=(ImageButton)findViewById(R.id.btn_back);
editPhoto=(ImageButton)findViewById(R.id.ibEditPhoto);
selectAction=(ImageButton)findViewById(R.id.ibSelectAction);
imgCamera=(ImageView)findViewById(R.id.imvProfilePhoto);
editPhoto.setOnClickListener(this);
selectAction.setOnClickListener(this);
back.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_back:
ProfilePhotoActivity.this.finish();
break;
case R.id.ibEditPhoto:
openFileChooser(null, null);
// startDialog();
break;
case R.id.ibSelectAction:
break;
}
}
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType){
try{
// Create AndroidExampleFolder at sdcard
File imageStorageDir = new File(
Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES)
, "AndroidExampleFolder");
if (!imageStorageDir.exists()) {
// Create AndroidExampleFolder at sdcard
imageStorageDir.mkdirs();
}
// Create camera captured image file path and name
File file = new File(
imageStorageDir + File.separator + "IMG_"
+ String.valueOf(System.currentTimeMillis())
+ ".jpg");
mCapturedImageURI = Uri.fromFile(file);
// Camera capture image intent
final Intent captureIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI);
Intent i = new Intent(Intent.ACTION_PICK);
// i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
// Create file chooser intent
Intent chooserIntent = Intent.createChooser(i, "Image Chooser");
// Set camera intent to file chooser
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS
, new Parcelable[] { captureIntent });
// On select image call onActivityResult method of activity
startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE);
}
catch(Exception e){
Toast.makeText(getBaseContext(), "Exception:"+e,
Toast.LENGTH_LONG).show();
}
}
protected void onActivityResult(int requestCode, int resultCode,Intent intent) {
if(requestCode==FILECHOOSER_RESULTCODE)
{
if (requestCode == GALLERY_PICTURE)
{
if (resultCode == RESULT_OK)
{
if (intent != null)
{
// our BitmapDrawable for the thumbnail
BitmapDrawable bmpDrawable = null;
// try to retrieve the image using the data from the intent
Cursor cursor = getContentResolver().query(intent.getData(), null, null, null, null);
if (cursor != null)
{
cursor.moveToFirst();
int idx = cursor.getColumnIndex(ImageColumns.DATA);
String fileSrc = cursor.getString(idx);
Bitmap galleryBitmap = BitmapFactory.decodeFile(fileSrc); // load preview image
galleryBitmap = Bitmap.createScaledBitmap(galleryBitmap, 200, 200, true);
String filePath = Environment.getExternalStorageDirectory()
.getAbsolutePath()+"/TimeChat/image/"+System.currentTimeMillis()+".jpg";
//imgCamera.setRotation(0);
imgCamera.setImageBitmap(galleryBitmap);
// writeToFile(filePath, galleryBitmap);
}
else
{
bmpDrawable = new BitmapDrawable(getResources(), intent.getData().getPath());
imgCamera.setImageDrawable(bmpDrawable);
}
}
else
{
Toast.makeText(getApplicationContext(), "Cancelled", Toast.LENGTH_SHORT).show();
}
}
else if (resultCode == RESULT_CANCELED)
{
Toast.makeText(getApplicationContext(), "Cancelled", Toast.LENGTH_SHORT).show();
}
}
else if (requestCode == CAMERA_REQUEST)
{
if (resultCode == RESULT_OK)
{
if (intent.hasExtra("data"))
{
// retrieve the bitmap from the intent
Bitmap cameraBitmap = (Bitmap) intent.getExtras().get("data");
String filePath = Environment.getExternalStorageDirectory()
.getAbsolutePath()+"/TimeChat/image/"+System.currentTimeMillis()+".jpg";
// update the image view with the bitmap
imgCamera.setImageBitmap(cameraBitmap);
// writeToFile(filePath, circleBitmap);
}
else if (intent.getExtras() == null) {
Toast.makeText(getApplicationContext(), "No extras to retrieve!", Toast.LENGTH_SHORT).show();
BitmapDrawable thumbnail = new BitmapDrawable(getResources(), intent.getData().getPath());
// update the image view with the newly created drawable
imgCamera.setImageDrawable(thumbnail);
}
}
else if (resultCode == RESULT_CANCELED) {
Toast.makeText(getApplicationContext(), "Cancelled", Toast.LENGTH_SHORT).show();
}
}
}
}
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
ProfilePhotoActivity.this.finish();
}
}
最佳答案
这看起来会是个问题:
if(requestCode==FILECHOOSER_RESULTCODE)
{
if (requestCode == GALLERY_PICTURE)
除非 FILECHOOSER_RESULTCODE 和 GALLERY_PICTURE 是相同的整数,否则语句永远不会通过。
关于android - 我想制作一个像 WhatsApp 个人资料照片对话框屏幕这样的对话框屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23825289/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 5年前关闭。 Improve this qu
我在此网站页脚中使用共享按钮。除了 url http://gnr.richkid.co.il/he/catalog/a/item/?ItemID=etc 的页面之外,whatsapp 按钮在所有页面中
这张图片在 WhatsApp 中流传,是带有 alpha 信息的 PNG 图像。如果您重新共享原始文件,则仅适用于 PNG。您尝试上传 PNG 文件(此文件或任何其他文件)的所有内容都会转换为 JPG
我在 Google 上做了很多研究。有很多教程和应用程序可以做到这一点。我测试了最知名的:App2SD、Link2SD、FolderMount。我什至购买了他们的商业版,以确保我启用了所有功能。好吧,
我使用 C# 创建了一个 Win 表单应用程序。这是向输入/选定的 Excel 文件手机号码发送批量 Whats App 消息。在制作这个软件的过程中,Whatsapp屏蔽了我的两个号码,原因是发送多
我在我的服务器上设置了 Yowsup。我关注了 this guide并设置一切没有任何错误。但是在最后一步,即发送消息时,它不会引发任何错误,但消息不会到达我手机上的 Whatsapp。 以下是输出供
我正在尝试实现一个 WhatsApp 机器人,它使用 chromedriver 并打开 whatsapp 网络,并向联系人发送消息。这些是程序的步骤: 从 excel 文件中读取联系人 设置发送消息的
我将WhatsApp语音消息(WhatsApp业务云API)中的音频文件发送到Google语音到文本识别。非常奇怪的是,它适用于从Windows WhatsApp客户端发送的语音消息。因此,让官方的W
是否可以将 IBM Watson Assistant(对话)与 WhatsApp 集成?我尝试在互联网上搜索,但没有找到太多。 最佳答案 我们正在努力与 Watson IBM 集成,这将带来 amio
我不确定这在这里是否离题,但我发现了其他 WhatsApp 问题。 如果我分享包含 IP 地址的链接,例如: http://123.456.789.456/mystuff WhatsApp 只为数字(
我正在尝试获取联系人的用户名、状态和上次查看数据的转储。 由于 WhatsApp 没有 API,因此我将其安装在 BlueStacks 上,并尝试拍摄可能存储这些详细信息的数据库的快照。 我有几个问题
是否可以使用 WhatsApp 服务器向 WhatsApp 组发送消息,在我自己的应用程序中而不打开 WhatsApp 应用程序? 另外,请帮助我了解 WhatsApp 联系人聊天的历史记录。 最佳答
我正在尝试从我的应用程序中选择联系人的 Whatsapp 地址,但鉴于我的应用程序是 Whatsapp 的实用程序,我希望用户继续使用选择联系人的 native 方式,这样他们不必习惯对我们大多数人来
假设我需要用户填写的表格很少,包括联系电话。填写完所有表格后,我希望该联系电话应该收到一条消息,其中包括一些问候语或单击以在表格中使用的一些文本或图像。该消息应作为简单的 SMS 和 WhatsApp
我正在尝试构建一个后台服务,我可以在其中将消息从我的 whatsapp 发送到其他用户的 whatsapp。我试过这段代码 PackageManager packageManager = getApp
如果您能在以下方面提供帮助,我们将不胜感激。通过我们的应用程序,用户可以启动 WhatsApp 消息(发生的情况是 WhatsApp 客户端以预加载的电话 + 文本开始,因此用户只需点击 WhatsA
我为类似的问题找到了很多线索,但在任何地方我都找不到我要找的东西。 给定联系人号码和短信,我想以编程方式向该联系人发送 WhatsApp 消息,而无需打开应用程序或选择联系人。 到目前为止,我已经编写
我的要求是在 Gallery/Albums 下显示目录, 以以下方式创建目录并不能完全满足我的要求... File rootPath = new File(Environment.getExtern
我知道如何使用 WhatsApp 官方 API 向任何号码发送消息 https://api.whatsapp.com/send?phone= 但是,如果用户加入该群组,有什么方法可以向 WhatsAp
我使用这段代码,但它显示了其他应用程序。 NSURL *URL = [[NSBundle mainBundle] URLForResource:@"ABC" withExtension:@"png"]
我是一名优秀的程序员,十分优秀!