我正在为我的Android应用程序创建一个服务,通过Intents向服务提供数据.问题是,当系统销毁服务时,提供给它的意图数据无法恢复,因此我的应用程序崩溃了.
我听说START_REDELIVER_INTENT只要有足够的内存可用于恢复提供给服务的意图数据就会重新启动我的服务,而START_STICKY不会恢复意图数据.
我对吗 ?还是有什么我不知道的?
此外,我的服务将在系统销毁后永远重启.

如果我错了,请纠正我:
1)甲服务被用来在后台执行长的任务.服务在UI线程中运行,因此如果有长任务,那么它可能会冻结我们的UI.只要我们告诉它停止,服务将继续独立于应用程序运行.
2)一种IntentService另一方面用于在单独的线程中执行短任务.它在完成任务时自动终止.
我该怎么做:
1)每5秒检查一次位置
2)如果位置发生变化,请将其发送到服务器并使用新的位置值更新UI
让我困惑的是:
我应该使用Service或IntentService,因为我需要在5秒后连续执行它,并且不希望我的UI线程无响应.
此应用程序将用于跟踪车辆.
我正在制作一个Android应用程序,在某些活动中显示一个小时分钟和秒钟的计时器.由于秒值将每秒更新一次,我正在考虑制作一个1000毫秒睡眠的线程,在每个周期后它将添加1到秒并更新文本视图.因此,它将计算分钟和小时并更新相应的文本视图.
但是我有一个疑问,线程可靠到足以完成这样的任务,还是我应该使用内置的库函数来在每个周期后获得几秒钟?如果我完全依赖线程计算时间,我有点担心让我的计时器失去同步.
我必须将数据上传到服务器.我正在使用与我的应用程序在同一进程上运行的服务.我应该使用单独的线程进行上传过程还是应该使用AsyncTask将数据上传到服务器?
更具体地说,我可以在服务类中使用AsyncTask吗?我应该使用它吗?此服务应始终在内存中运行,以便每5秒向服务器发送一次数据.
我正在制作一个应用程序,每 10 秒自动从后置摄像头拍摄一张照片。但问题是我无法检测预览是否已开始。我想在相机预览可用时立即拍照。有人知道相机预览准备好时触发的方法吗?
我想以编程方式为视图的顶部地图填充设置动画,但我不知道如何执行此操作.
private GoogleMap map;
map.setPadding(left, top, right, bottom);
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何动画top填充值从0到100?
我正在制作一个Android应用程序并使用android-support-v7-appcompat来确保我的应用程序支持Android 2.2及更高版本的操作栏.
我需要制作Action Bar叠加层并使用半透明背景,因此我已将styles.xml修改为此代码:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<!-- TRANSLUCENT THEME -->
<style name="TranslucentAB" parent="Theme.AppCompat.Light">
<item name="windowActionBarOverlay">true</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">@style/BlackBar</item>
<item name="actionBarStyle">@style/BlackBar</item>
</style>
<!-- TRANSLLUCENT COLOR STYLE -->
<style name="BlackBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/halfblack</item>
<item …Run Code Online (Sandbox Code Playgroud) 我String TIMESTAMP以这种格式从服务器获取MySQL的日期和时间:
2014-02-15 05:18:08
Run Code Online (Sandbox Code Playgroud)
我想要的是以DD-MM-YYYY格式提取日期和格式时间HH:MM:SS AM/PM.此时间戳的时区也不同,我希望它在印度时区(IST).
记住timestamp是String数据类型.
我正在使用appcompat v7库来支持api级别8及以上的操作栏.我正在尝试更改操作栏标题文本的颜色.
GingerBread中标题文本的颜色正在改变,但是当我使用JellyBean在手机上运行应用程序时,颜色不会改变.
在GingerBread标题颜色变为红色:

在JellyBean上它仍然是黑色的:

这是我的styles.xml:
styles.xml:
<resources>
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
<item name="actionBarStyle">@style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="titleTextStyle">@style/TitleBarTextColor</item>
</style>
<style name="TitleBarTextColor" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/red</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
styles.xml for v-11:
<resources>
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
<item name="actionBarStyle">@style/ActionBarStyle</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
style.xml for v-14:
<resources>
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
<item name="actionBarStyle">@style/ActionBarStyle</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
Mainfest:
android:theme="@style/AppTheme"
Run Code Online (Sandbox Code Playgroud) 我正在尝试制作自定义列表视图.列表视图中的每个条目都将具有imageview,textview和radiobutton.我终于做了清单,但现在我在选择单选按钮时遇到了问题.
我想要的是每当用户点击条目中的任何地方时,这应该设置相应的单选按钮并自动取消选择列表中的其他单选按钮.
这是我的代码:bus_item.xml: -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imglist_icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:layout_margin="10dp"
android:src="@drawable/alaknanda" />
<TextView
android:id="@+id/txtlist_name"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="Alaknanda"
android:textSize="22sp"
android:textStyle="bold" />
<RadioButton
android:id="@+id/radio_list"
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
BusListActivity.java: -
package com.hpubts50.hpubustrackerserver;
import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.TextView;
public class BusListActivity extends ListActivity {
@Override
protected void onCreate(Bundle …Run Code Online (Sandbox Code Playgroud) 所以我开发了一个Android应用程序,它使用融合位置(LocationClient)每5秒确定用户的位置,并将此数据发送到我的服务器.当应用程序运行时,整个过程每5秒重复一次.我正在使用AsyncTask类在后台上传数据.
问题:
当用户关闭应用程序或手机进入睡眠状态时,数据上传将停止.
我想要的是:
我希望应用程序能够连续将位置数据发送到我的服务器,即使用户关闭应用程序或手机处于睡眠状态时也是如此.这个过程应该在一个单独的线程上运行,因为我不希望这个过程使我的UI线程无响应.
我到现在所发现的:
我听说过服务,intentservices和alarmmanager但我不知道使用哪一个.我也听说过唤醒锁,迫使CPU不要睡觉.请记住,我不想一直打开屏幕,因为这会耗尽电池电量.
如何让我的应用程序始终将数据发送到服务器?
我制作了一个应用程序,它从 url 下载图像(使用Universal Image Loader库)并将该图像显示在TouchImageView. 我使用触摸图像视图来实现捏缩放功能。我按照本教程学习了如何使用 TouchImageView。
问题是,每当我放大由通用图像加载器下载的图像并将另一个图像加载到 TouchImageView 中时,新图像就会被拉伸和扭曲。当通过缩小先前缩放的图像恢复到原始大小,然后加载新图像时,这个问题就得到了解决。
因此可以通过缩小加载的图像然后加载新图像来解决该问题。但我不知道如何重置缩放,并且库没有提供这方面的功能。
我尝试使用最新版本TouchImageView(其中包括重置图像功能),但较新版本与 不兼容,UIL而且该教程似乎仅使用原始库中的部分代码(尽管其工作正常)。
有谁知道如何重置放大吗TouchImageView?
**强文字**代码:
package com.hpubts50.hpubustracker;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.widget.ImageView;
public class TouchImageView extends ImageView {
Matrix matrix ;
// We can be in one of these 3 states
static final int NONE = 0;
static final int DRAG = 1; …Run Code Online (Sandbox Code Playgroud)