请问任何人都可以告诉我如何使用AsyncTask在后台使用http帖子以及如何将参数传递给AsyncTask?我发现的所有示例对我来说都不够清楚,而且它们是关于下载文件的.
我在我的主要活动中运行此代码,我的问题是当代码将信息发送到服务器时,应用程序速度减慢,好像它被冻结了2到3秒,然后它继续正常工作,直到下一次发送.此http帖子向服务器发送四个变量(book,libadd和time),第四个是固定的(名称)
提前致谢
public void SticketFunction(double book, double libadd, long time){
Log.v("log_tag", "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SticketFunction()");
//HttpClient
HttpClient nnSticket = new DefaultHttpClient();
//Response handler
ResponseHandler<String> res = new BasicResponseHandler();
HttpPost postMethod = new HttpPost("http://www.books-something.com");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(5);
nameValuePairs.add(new BasicNameValuePair("book", book+""));
nameValuePairs.add(new BasicNameValuePair("libAss", libass+""));
nameValuePairs.add(new BasicNameValuePair("Time", time+""));
nameValuePairs.add(new BasicNameValuePair("name", "jack"));
//Encode and set entity
postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));
//Execute
//manSticket.execute(postMethod);
String response =Sticket.execute(postMethod, res).replaceAll("<(.|\n)*?>","");
if (response.equals("Done")){
//Log.v("log_tag", "!!!!!!!!!!!!!!!!!! SticketFunction got a DONE!");
}
else Log.v("log_tag", "!!!!!!!?????????? SticketFunction Bad or no …Run Code Online (Sandbox Code Playgroud) 我正在使用1个XML中的Imageview和Button,我正在从webServer中将图像作为URL重新显示并在ImageView上显示它.现在,如果单击按钮(保存),我需要将该特定图像保存到SD卡中.这该怎么做?
注意:当前图像应保存.
我有几个关于android源代码下载,repo/git的问题.
此页面显示源下载大小约为6GB,但是当我下载时,我的目录大小为11GB.我做错了什么?
我下载源代码使用
repo init -u https://android.googlesource.com/platform/manifest
它是否为所有版本的Android下载源代码?如果是这样,我没有看到不同版本的单独目录.如何检查/列出所有可用版本?
如果我使用了它会发生什么变化
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1?
还repo branches输出(no branches)
我只是用回购检查了主人.现在我想切换到froyo.如果不再下载一堆东西我怎么能这样做?我不想再次下载一堆东西,我只是想在分支之间自由移动,就像在普通的git clone中一样.
在我的活动中:
<activity
android:name=".MainActivity"
android:screenOrientation="landscape"
android:launchMode="singleTask"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
Run Code Online (Sandbox Code Playgroud)
我onNewIntent用来处理新的意图.我不需要处理历史中的意图,并且在开始时我已经放了这段代码
if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
return;
}
Run Code Online (Sandbox Code Playgroud)
但是,此标志未设置为Kindle Fire上的历史意图.在其他Android设备上,此代码运行良好.也许有其他方法可以避免处理历史意图?
我想使用google java客户端API获取我的GoogleAccount中的所有日历.
在我的应用程序中,我希望用户可以在日历中选择他的事件将被保存(不仅仅是默认值).但是因此我需要他们的CalendarID.我不希望用户必须搜索他们的日历ID以手动将其写入应用程序.
是否可以在他的帐户中创建一个新日历,以便在这个新帐户中编写所有事件.
对不起,我的英语不好.
我正在阅读有关GCM的内容,同时我正在尝试在文档(extras/google/gcm/gcm-server/)和文档中给出的示例代码extras/google/gcm/gcm-client/.
客户(设备)的注册过程正常.但是,当我尝试向已注册的设备发送消息时,即使添加了一个设备或将多个设备添加到服务器,它也会给我错误.
这是代码:
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException, ServletException {
List<String> devices = Datastore.getDevices();
StringBuilder status = new StringBuilder();
if (devices.isEmpty()) {
status.append("Message ignored as there is no device registered!");
} else {
List<Result> results;
// NOTE: check below is for demonstration purposes; a real application
// could always send a multicast, even for just one recipient
if (devices.size() == 1) {
// send a single message using plain post
String registrationId …Run Code Online (Sandbox Code Playgroud) 我在我的s2上有一个预定义的应用程序,让我收听广播.它不使用互联网,而是使用周围的无线电波.有什么方法可以使用该功能以编程方式启动无线电并搜索广播电台?
我是Android开发人员.在我的工作中,我必须每天上传一个新版本的应用程序.
问题是将近三到四周我每次尝试上传到市场时都会出现以下错误.
The server could not process your apk. Try again.
Run Code Online (Sandbox Code Playgroud)
重试近20次后,应用程序正在上传.任何人都可以解释发生了什么,问题是我的还是在Android市场....请给我一个解决方案.
提前致谢.
此致,狙击手
我正在使用一个使用Geopoints的Android应用程序,我想从另一个Geopoint确定一个Geopoint,一个距离(任何格式)和一个极角.例如,我想通过手机中的GPS获取我位置的北 - 东北(22,5度)100米处的坐标.
我发现的唯一方法是Location.distanceBetween(...).
android ×10
java ×2
amazon ×1
android-maps ×1
api ×1
calendar ×1
events ×1
google-play ×1
gps ×1
http ×1
intentfilter ×1
kindle-fire ×1
post ×1