我创建了一个发送带有录音的电子邮件的应用程序,当意图被触发并且选择电子邮件作为发送附件的应用程序时,您可以看到有附件但附件未送达.
Intent sendIntent = new Intent(Intent.ACTION_SEND);
//Mime type of the attachment (or) u can use sendIntent.setType("*/*")
sendIntent.setType("audio/3gp");
//Subject for the message or Email
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "My Recording");
//Full Path to the attachment
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(fileName));
//Use a chooser to decide whether email or mms
startActivity(Intent.createChooser(sendIntent, "Send email..."));
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我正在开发短信发送应用程序,并且出于登录目的,我想使用POST方法从我的Android应用程序向网络服务器发送用户名和密码.
当我点击lo-gin按钮时,应用程序没有响应,并且控制台打印以下消息以响应Post请求.
HTTP/1.1 500内部服务器错误
虽然我的应用程序运行良好的GET方法.
我无法弄清楚为什么会造成这种情况......
整个代码在这里:
package com.vikas.httplogin;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class HttpLogin extends Activity {
TextView tv;
private static final String tag ="FATAL_ERROR";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
connecttoServer();
}
private void connecttoServer()
{ …Run Code Online (Sandbox Code Playgroud) 我有一个GridView自定义View,它是一个Button和一个TextView.我定义了setOnItemClickListener它,但看起来它从未被调用,请参阅下面的代码和平.
gridview = (GridView) findViewById(R.id.main_gridview);
gridview.setAdapter(new GridAdapter(this));
gridview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getApplicationContext(), "gadsfadsf",
Toast.LENGTH_SHORT).show();
Log.d("Main", "onItemClick");
}
});
Run Code Online (Sandbox Code Playgroud) 我正在制作一个Android应用程序,一旦按下按钮,一旦收到包含相同文本的SMS消息,就会从textview将文本文件写入SD卡.
收到短信后,如何将文本文件保存到SD卡并从该文本文件中读取?这是我到目前为止的代码:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.telephony.gsm.SmsMessage;
import android.widget.Toast;
import android.media.MediaPlayer;
public class IncomingSmsCaptureApp extends BroadcastReceiver {
MediaPlayer mp1;
@Override
public void onReceive(Context context, Intent intent) {
File sdcard = Environment.getExternalStorageDirectory();
//Get the text file
File file = new File(sdcard,"Notes\file.txt");
//Read text from file
String text = new String();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) …Run Code Online (Sandbox Code Playgroud) 我有两个不同的活动.第一个发射第二个.
Intent intent = new Intent(this, Activity2.class);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
在第二个活动中,我调用System.exit(0).我认为第一个活动是由"页面堆栈"引起的.但我发现发生了两件事.
applicationContext.openFileOutput(fileName, Context.MODE_PRIVATE); 在那种情况下沙箱是否被清理干净?通过'返回键'或甚至android.os.Process.killProcess(android.os.Process.myPid())是沙盒中的文件保持正常退出.那么,System.exit(0)执行时实际发生了什么?
谢谢!
我的应用程序中有许多产品网格.当用户选择网格中的一个项目时,我将开始一个新的活动作为DIALOG框并显示项目的名称,数量和图像.但我无法动态发送图像源.
这是我的代码
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,int position, long id) {
//Toast.makeText(getApplicationContext(),((TextView) v.findViewById(R.id.grid_item_label)).getText(), Toast.LENGTH_SHORT).show();
Intent item_intent = new Intent(MainActivity.this, Item.class);
item_intent.putExtra("name",((TextView) v.findViewById(R.id.grid_item_label)).getText());
item_intent.putExtra("quantity",((TextView) v.findViewById(R.id.grid_item_quantity)).getText());
//my problem is here***************************************************
ImageView my_image = findViewById(R.id.grid_item_image).getDrawable();
item_intent.putExtra("image",my_image.getXXXXX());
//*********************************************************************
MainActivity.this.startActivity(item_intent);
}
});
Run Code Online (Sandbox Code Playgroud)
我应该使用什么来从ImageView获取图像源?
我有这个XML代码生成一个按钮,一个textview和另一个按钮,如何让按钮出现在最左边,中心的textview和最右边的最后一个按钮?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel">
</Button>
<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Place">
</TextView>
<Button android:id="@+id/Button03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save">
</Button>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我正在开发在Android 1.5和Andoroid 2.x平台上运行的应用程序.当我在Android 2.2上安装它时一切正常,但在使用Android 1.5的模拟器上我收到错误:
Failure [INSTALL_FAILED_DEXOPT]
Run Code Online (Sandbox Code Playgroud)
可能是什么问题?
UPD即Logcat输出:
09-26 07:12:22.484: INFO/PackageManager(579): /data/app/vmdl23706.tmp changed; unpacking
09-26 07:12:22.494: DEBUG/installd(557): DexInv: --- BEGIN '/data/app/vmdl23706.tmp' ---
09-26 07:12:36.114: ERROR/dalvikvm(1362): LinearAlloc exceeded capacity, last=336
09-26 07:12:36.114: ERROR/dalvikvm(1362): VM aborting
09-26 07:12:36.265: INFO/DEBUG(551): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
09-26 07:12:36.265: INFO/DEBUG(551): Build fingerprint: 'generic/sdk/generic/:1.5/CUPCAKE/150240:eng/test-keys'
09-26 07:12:36.265: INFO/DEBUG(551): pid: 1362, tid: 1362 >>> /system/bin/dexopt <<<
09-26 07:12:36.265: INFO/DEBUG(551): signal 11 (SIGSEGV), fault addr deadd00d …Run Code Online (Sandbox Code Playgroud) 我已经创建了一个opengl表面,一切正常,但是当我尝试使用以下方法在其上绘制文本时:
public void loadFPSTexture(GL10 gl){
Bitmap bitmap = Bitmap.createBitmap(256, 256, Bitmap.Config.RGB_565);
bitmap.eraseColor(Color.BLACK);
Canvas canvas = new Canvas(bitmap);
Paint textPaint = new Paint();
textPaint.setTextSize(35);
textPaint.setFakeBoldText(true);
textPaint.setAntiAlias(true);
textPaint.setARGB(255, 255, 255, 255);
canvas.drawText("FPS "+reportedFramerate, 10,35, textPaint);
gl.glGenTextures(1, texturesFPS, 0);
gl.glBindTexture(GL10.GL_TEXTURE_2D, texturesFPS[0]);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
bitmap.recycle();
}
Run Code Online (Sandbox Code Playgroud)
然后在我的onDraw函数中使用:
gl.glPushMatrix();
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glBindTexture(GL10.GL_TEXTURE_2D, texturesFPS[0]);
gl.glTranslatef(-surfaceSize.x/1.5f, surfaceSize.y/1.5f, 0.0f);
gl.glScalef(10, 10, 1.0f);
gl.glColor4f(1.0f, 1.0f, 1.0f, saturation_head);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0,vertexBuffer);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureFPSBuffer); …Run Code Online (Sandbox Code Playgroud) 这是我第一次活动中的代码:
Intent i = new Intent(this, OtherScreen.class);
i.putExtra("id1", "first");
i.putExtra("id2", "second");
startActivity(i);
Run Code Online (Sandbox Code Playgroud)
第一个,第二个是我想要传递的值.在我的另一堂课上我有这个:
Intent i = getIntent();
Bundle extras = i.getExtras();
String result = extras.getString("id1");
System.out.println("yeah"+result);
Run Code Online (Sandbox Code Playgroud)
但是在我运行之后,我的结果是空的.你能帮助我吗?如果我以这种方式编写我的getString,我会收到语法错误.
String result = extras.getString(id1); //id1 cannot be resolved to a variable
String result = extras.getString("id1","default value"); // remove argument
Run Code Online (Sandbox Code Playgroud) android ×10
java ×3
alignment ×1
attachment ×1
canvas ×1
email ×1
frame-rate ×1
http ×1
kill-process ×1
layout ×1
opengl-es ×1
storage ×1
text ×1
xml ×1