因为它或多或少是我想要实现的.我希望我的GPS服务在后台运行,不断收集GPS坐标并将它们保存到数组中,这样用户可以交换到另一个活动并返回到Map活动并使其仍然绘制最多的整个记录路径.
所以我实现了这个教程来设置IPC,它似乎或多或少有效,但我在将数据恢复到我的Activity时遇到了问题.这是我的文件,首先是我的Parcelable对象,它是一个包含GPSObject的列表.接下来是我的GPSObject,它只是一个可序列化的对象,包含来自android Location对象的一些信息.
package com.android.SnowFever;
import java.util.ArrayList;
import java.util.List;
import com.android.SnowFever.*;
import com.google.android.maps.GeoPoint;
import android.os.Parcel;
import android.os.Parcelable;
public final class GPSResult implements Parcelable {
public static final Creator<GPSResult> CREATOR = new Creator<GPSResult>() {
@Override
public GPSResult[] newArray(int size) {
return new GPSResult[size];
}
@Override
public GPSResult createFromParcel(Parcel source) {
return new GPSResult(source);
}
};
private List<GPSObject> geoPoints;
public GPSResult() {
geoPoints = new ArrayList<GPSObject>();
}
@SuppressWarnings("unchecked")
private GPSResult(Parcel source) {
geoPoints = source.readArrayList(GPSService.class.getClassLoader());
}
public void addGPS(GPSObject location) …Run Code Online (Sandbox Code Playgroud) 我想在Android中创建一个PDF查看器..
那有可能吗?如果是的话,任何人都可以向我推荐一些示例代码或指南.
我是使用smack库和制作一个聊天应用程序的新手.我已经做了很多工作,在这一步我想问两个问题.
当我添加一个朋友时,朋友已添加到我的列表中,但没有任何通知发送给我已添加的FRIEND,如何实现相同.我在下面添加了代码.
我要问的第二件事是,我如何检查我要添加的用户是否是应用程序的一部分或成员(意味着它是否在服务器上).因此,不应将未注册到应用程序的用户添加到好友列表中.
这是代码
public static boolean addFriend(String jid) {
String nickname = null;
nickname = StringUtils.parseBareAddress(jid);
RosterEntry entry4 = roster.getEntry("samsad");
if (!roster.contains(jid)) {
try {
Presence subscribe = new Presence(Presence.Type.subscribe);
subscribe.setTo(jid);
connection.sendPacket(subscribe);
roster.createEntry(jid, nickname, null);
// Send a roster entry (any) to user2
RosterExchangeManager REM = new RosterExchangeManager(connection);
REM.send(entry4, jid);
return true;
} catch (XMPPException e) {
System.err.println("Error in adding friend");
return false;
}
} else {
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
在后台运行服务的名册交换经理
/**Remotr Exchange Manager*/
RosterExchangeManager rem = new …Run Code Online (Sandbox Code Playgroud) 我一直在读Android(就像大多数移动操作系统一样)不会"退出"应用程序.
当我们按下后退按钮时,应用程序仍处于后台(就像一个谜语状态).
所以,我想知道,当后台运行的应用程序太多时它会做什么呢?
有人知道如何在Android上使用FFMPEG将YUV420帧转换为H.264吗?
我已经用NDK在Android上移植了FFMPEG,我只是不知道如何使用它.赞赏源代码.
有没有办法获得当前设置的图像的尺寸ImageButton?我正在努力实现这一目标.
我ImageButton的默认图片为36 x 36.然后我选择尺寸为200 x 200的图片.我想打电话给:
imageButton.setImageBitmap(Bitmap.createScaledBitmap(
bitmap, 36, 36, true));
Run Code Online (Sandbox Code Playgroud)
将图像缩小到36 x 36.我想要获得原始图像大小的原因是为了满足hdpi,mdpi和ldpi,所以我可以将位图的尺寸分别设置为36 x 36,24 x 24和18 x 18把它添加到ImageButton.有任何想法吗?
哦,伙计,我随机摆弄代码后得到了答案:
imageButton.getDrawable().getBounds().height();
imageButton.getDrawable().getBounds().width();
Run Code Online (Sandbox Code Playgroud) 我倾注了类似的问题,但找不到答案.我希望能够长时间在我的webview中按下用户上传的图像来保存它们(就像你可以在浏览器中一样).有帮助吗?
更新:
现在使用我自己的自定义项目"保存图像"弹出上下文菜单.我甚至可以成功干杯msgs.我如何保存图像呢?长时间点击的图像是否会传递到我的菜单项?
public boolean onLongClick(View v) {
openContextMenu(v);
return true;
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context, menu);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
switch (item.getItemId()) {
case R.id.save_image:
Toast.makeText(this, "save failed",
Toast.LENGTH_LONG).show();
return true;
default:
return super.onContextItemSelected(item);
}
}
Run Code Online (Sandbox Code Playgroud) 如何在没有消息的情况下显示进度对话框?
我只需要显示不确定的圆圈.在不创建自定义对话框的情况下,最简单,最快速的方法是什么?有没有类似的方法:
progressDialog.setShowIndeterminateCircleOnly(true)
我在微调器中设置了动态值.我正在使用以下代码.
spinner_generalbooks.setAdapter(new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_item, new String[]{"Author","ISBN","Keyword","Title"}));
Run Code Online (Sandbox Code Playgroud)
它工作正常,但我对旋转器的视图有问题.如果我们选择simple_spinner_item,它在正常状态下是正常的,但是当我们想要改变它时,行非常窄而不是CheckedTextView在普通的微调器选项中CheckedTextView.如果我们选择simple_spinner_dropdown_item,选项会随附CheckedTextView,但在正常状态下,它看起来与图片中的不同
(第一个是默认微调器,第二个是使用simple_spinner_dropdown_item).

我想将spinner显示为默认的微调器.怎么做?