如果您想了解多线程–监控数百个实时设备时如何使我的应用程序运行良好?和多监控软件的知识,那么本篇文章将是您的不二之选。我们将深入剖析多线程–监控数百个实时设备时如何使我的应用程序运行良好?的各个方面,
如果您想了解多线程 – 监控数百个实时设备时如何使我的应用程序运行良好?和多监控软件的知识,那么本篇文章将是您的不二之选。我们将深入剖析多线程 – 监控数百个实时设备时如何使我的应用程序运行良好?的各个方面,并为您解答多监控软件的疑在这篇文章中,我们将为您介绍多线程 – 监控数百个实时设备时如何使我的应用程序运行良好?的相关知识,同时也会详细的解释多监控软件的运用方法,并给出实际的案例分析,希望能帮助到您!
本文目录一览:- 多线程 – 监控数百个实时设备时如何使我的应用程序运行良好?(多监控软件)
- android – Eclipse不会让我的应用程序运行
- android – ListView使我的应用程序运行速度很慢,虽然我创建了Holder Class
- android – 如何在安装或删除其他应用程序时使我的应用程序接收广播
- android – 如何在每个打开同一个蓝牙低能量设备时重新连接我的应用程序?
多线程 – 监控数百个实时设备时如何使我的应用程序运行良好?(多监控软件)
我正在寻求开发这个应用程序的建议,避免100%的cpu消耗,并最大限度地减少RAM的使用量.换句话说,我希望我的应用程序保持响应,而不是阻止系统或消耗所有资源.
我主要关心的是使用线程监视每个远程设备.我的应用程序可以创建的线程数量有限制吗?可以使用低或中等优先级启动线程以最大限度地减少cpu消耗吗?
关于最佳内存使用的建议也是值得欢迎的.
解决方法
android – Eclipse不会让我的应用程序运行
Installation error: INSTALL_PARSE_Failed_NO_CERTIFICATES
我正在使用Eclipse.我以前从未见过这个问题.我已经在手机上运行了数百次应用程序.我的项目的任何文件都没有明显的错误.我编辑了提升版本的Manifest文件,但它没有用.我清理了我的项目.我从手机上卸载了当前版本的应用程序.但这一切都无效.
我完全不知道问题是什么. LogCat声称我的main.xml文件存在问题.
ERROR/PackageParser(956): Package ##MY PACKAGE NAME has no certificates at entry res/layout/main.xml; ignoring!
我没有碰过这个文件,所以我不知道可能是什么问题.
更新:事情变得更加混乱.在问题发生之前,我将几个png文件拖放到drawable文件夹中(已经有几个).把我的头发拉出来后,我突然意识到问题可能就是这些文件.我删除了它们(共5个),现在可以使用了.唯一的问题是我不知道为什么他们搞砸了安装.
解决方法
解决方法是导出未签名的包并使用signapk.jar手动签名
逐字:
Comment 26 by lucasiturbide,Apr 14,
2010 Hi everybody. I have solved this
in my project by signing the APK with
the debugkey and the jarsigner tool
provided by android tools.Just execute this:
jarsigner -verbose -keystore <userhome>/.android/debug.keystore <package.apk> androiddebugkey
and you will have your nice fresh and
working apk for debugging only
purpose. Remember you have to sign
your APK with a valid signature to
publish your application at the Market
使用别名“androiddebugkey”的调试密钥的密码是“android”.
android – ListView使我的应用程序运行速度很慢,虽然我创建了Holder Class
我对这个问题变得非常绝望,而且我一直在尝试你在其他线程中发布的所有想法.
问题是我的程序大量调用getView()方法,并且我实现了Holder范例,但它仍然非常慢,也许有人可以启发我?
这是我的Adapter类:
import java.util.ArrayList;
import android.content.Context;
import android.location.Location;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class IconListViewAdapterPharmacy extends ArrayAdapter<PharmacyListItem>
{
private ArrayList<PharmacyListItem> items;
private Context cont;
private Location l;
public IconListViewAdapterPharmacy(Context cont, int textViewResourceId, ArrayList<PharmacyListItem> items, Location l)
{
super(cont, textViewResourceId, items);
this.cont = cont;
this.items = items;
this.l = l;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
PharmacyListItem o = items.get(position);
ViewHolder holder = new ViewHolder();
if (v == null)
{
LayoutInflater vi = (LayoutInflater)cont.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.icon_row_pharmacy, null);
holder.tt = (TextView) v.findViewById(R.id.pharmacy_row_toptext);
holder.address = (TextView) v.findViewById(R.id.pharmacy_row_address);
holder.distance = (TextView) v.findViewById(R.id.pharmacy_row_distance);
holder.telephone = (TextView) v.findViewById(R.id.pharmacy_row_telephone);
// associate the holder with the view for later lookup
v.setTag(holder);
}
else
{
holder = (ViewHolder)convertView.getTag();
}
holder.tt.setText(o.getName());
String add = "" + o.getAddress();
holder.address.setText("" + add.substring(0, add.lastIndexOf(",")));
holder.telephone.setText("" + o.getTelephone());
String distancia = "" + o.getdistance();
if(l != null)
holder.distance.setText("distancia: " + distancia);
return v;
}
static class ViewHolder
{
TextView tt;
TextView address;
TextView distance;
TextView telephone;
}
}
PharmacyListItem类:
import android.location.Location;
public class PharmacyListItem
{
private String name;
private double lat;
private double lng;
private String telephone;
private double distance;
public PharmacyListItem(Location l, String name, double lat, double lng , String telephone)
{
this.name = name;
this.lng = lng;
this.lat = lat;
this.telephone = telephone;
Location l2 = new Location(l);
l2.setLatitude(lat);
l2.setLongitude(lng);
distance = l.distanceto(l2);
}
public String getName()
{
return name;
}
public String getAddress()
{
return GeoLocator.getAddress(lat, lng);
}
public String getTelephone()
{
return telephone;
}
public String getdistance()
{
return (""+distance).substring(0, (""+distance).indexOf(".")) + "m.";
}
public double getdist()
{
return distance;
}
}
任何想法将不胜感激!
谢谢你们!
编辑我粘贴我的.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip"
android:layout_marginRight="4dip"
android:background="@drawable/bg_detalle_1">
<ImageView
android:id="@+id/arrow2"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:singleLine="true"
android:ellipsize="marquee"
android:layout_marginRight="4dip"/>
<LinearLayout android:padding="10dip" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout3" android:orientation="vertical">
<LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout1" android:layout_width="match_parent">
<TextView android:gravity="center" android:textColor="#525252" android:layout_height="fill_parent" android:singleLine="true" android:ellipsize="marquee" android:text="" android:textandroid:id="@+id/pharmacy_row_toptext" android:layout_width="wrap_content" android:layout_marginRight="6dip"></TextView>
</LinearLayout>
<LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout2" android:layout_width="match_parent">
<TextView android:layout_height="fill_parent" android:text="TextView" android:id="@+id/pharmacy_row_address" android:layout_width="wrap_content" android:layout_marginRight="6dip"></TextView>
</LinearLayout>
<LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/linearLayout5">
<TextView android:gravity="center" android:layout_height="fill_parent" android:text="TextView" android:singleLine="true" android:ellipsize="marquee" android:layout_width="wrap_content" android:id="@+id/pharmacy_row_telephone"></TextView>
</LinearLayout>
<LinearLayout android:layout_gravity="right" android:layout_height="wrap_content" android:id="@+id/linearLayout5" android:layout_width="match_parent">
<TextView android:layout_height="fill_parent" android:text="TextView" android:singleLine="true" android:ellipsize="marquee" android:layout_width="wrap_content" android:id="@+id/pharmacy_row_distance"></TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
解决方法:
而不是这个
public IconListViewAdapterPharmacy(Context cont, int textViewResourceId, ArrayList<PharmacyListItem> items, Location l)
{
super(cont, textViewResourceId, items);
this.cont = cont;
this.items = items;
this.l = l;
}
做这个
public IconListViewAdapterPharmacy(Context cont, int textViewResourceId, ArrayList<PharmacyListItem> items, Location l)
{
super(cont, textViewResourceId, items);
this.l = l;
}
然后在getView访问项中使用getItem(position)而不是items.get(position)并获取上下文调用getContext().
不知道这是否会改善性能.但尝试没有害处.这也是正确的方法.
编辑:
如果您有要下载和显示的配置文件图像,可以像以后一样获取地址并更新UI.
String add = "" + o.getAddress();
if (TextUtils.IsEmpty(add)) {
// download the geolocation. pass the position to the downloader thread which will update the item at position with address, after fetching is complete.
new GetAddresstask(position).execute(o);
}
这将释放UI线程专注于显示listview.
class GetAddresstask extends Asynctask<.......> {
int mPosition = -1;
public void GetAddresstask(int position) {
mPosition = position;
}
String doInBackground(parameters) {
return GeoLocation.getaddress(parameter[0]);
}
void onPostExecute(String result) { // this runs on UI thread.
// use mPosition here.
// update addapter item with this address thats in 'result' variable.
// and call adapter.notifyDatasetInvalidated()
}
android – 如何在安装或删除其他应用程序时使我的应用程序接收广播
我想创建一个可以在安装或删除设备上的其他应用程序时接收广播的应用程序.
我的代码
在表现:
<receiver android:name=".apps.AppListener">
<intent-filter android:priority="100">
<action android:name="android.intent.action.PACKAGE_INSTALL"/>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
</intent-filter>
</receiver>
在AppListener中:
import android.content.broadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class AppListener extends broadcastReceiver {
@Override
public void onReceive(Context context, Intent arg1) {
// Todo Auto-generated method stub
Log.v(TAG, "there is a broadcast");
}
}
但我无法收到任何广播.我认为这个问题是由于应用权限,任何想法?
谢谢你的帮助.
解决方法:
在你的清单中:
<receiver android:name=".apps.AppListener">
<intent-filter android:priority="100">
<action android:name="android.intent.action.PACKAGE_INSTALL"/>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
</intent-filter>
</receiver>
在intent-filter标记之前添加该行
<data android:scheme="package"/>
所以你的清单应该是这样的:
<receiver android:name=".apps.AppListener">
<intent-filter android:priority="100">
<action android:name="android.intent.action.PACKAGE_INSTALL"/>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
我不确定PACKAGE_REMOVED意图,如果它实际可用.
android – 如何在每个打开同一个蓝牙低能量设备时重新连接我的应用程序?
我的目标是:一天之后,当用户重新打开应用程序时,应用程序将不得不记住有缺陷的设备,并且必须尝试重新连接它.
现在我以这种方式获得了我的目标:
>我最好记住所选设备的mac地址
>当用户重新打开应用程序时,应用程序执行隐藏的扫描,并尝试重新连接到具有相同MAC地址的设备.
>为了检索mac地址我使用函数getAddress()(当我尝试连接到这个功能给我的android外设
一些问题,因为设备每个更改他的MAC地址
开始:/)
有一个最好的方式来获得同样的事情吗?
关闭主题:ScanScult的功能onScanResult有一段时间返回给我的设备,是不是正常?
我已经使用了startLeScan(UUID [] serviceUuids,BluetoothAdapter.LeScanCallback回调),而在棒棒糖之后,我使用了新版本的startLeScan与Scanfilter.这可能是问题吗?
解决方法
5.4.5 Privacy Feature
Bluetooth LE supports a feature that reduces the ability to track a LE device over a period of time by changing the
Bluetooth device address on a frequent basis. The privacy feature is
not used in the GAP discovery mode and procedures but it is used,when
supported,during connection mode and connection procedures. In order
for a device using the privacy feature to reconnect to kNown devices,
the device address,referred to as the private address,must be
resolvable by the other device.The private address is generated using
the device’s resolving identity key (IRK) exchanged during the bonding
procedure.
所以理想的方法是使用IRK来实现设备的实际地址.但是我没有找到任何API来做.
目前,我在mny应用程序中使用的工作重新连接到设备,
>循环遍历所有可用的设备.
>获得序列号,如果序列号不匹配已存储的号码
然后断开连接.
>对所有设备重复步骤2.
如果设备通过某些服务暴露了序列号,这项工作将会起作用.
您也可以在调用connectGatt (Context context,boolean autoConnect,BluetoothGattCallback callback)时尝试将autoconnect标志设置为true
从文档:
public BluetoothGatt connectGatt (Context context,
BluetoothGattCallback callback) Added in API level 18Connect to GATT Server hosted by this device. Caller acts as GATT
client. The callback is used to deliver results to Caller,such as
connection status as well as any further GATT client operations. The
method returns a BluetoothGatt instance. You can use BluetoothGatt to
conduct GATT client operations. ParametersautoConnect Whether to
directly connect to the remote device (false) or to automatically
connect as soon as the remote device becomes available (true).callback GATT callback handler that will receive asynchronous callbacks. Throws IllegalArgumentException if callback is null
今天关于多线程 – 监控数百个实时设备时如何使我的应用程序运行良好?和多监控软件的讲解已经结束,谢谢您的阅读,如果想了解更多关于android – Eclipse不会让我的应用程序运行、android – ListView使我的应用程序运行速度很慢,虽然我创建了Holder Class、android – 如何在安装或删除其他应用程序时使我的应用程序接收广播、android – 如何在每个打开同一个蓝牙低能量设备时重新连接我的应用程序?的相关知识,请在本站搜索。
本文标签: