小编che*_*gbo的帖子

如何为Android 4.0创建AVD

Android 4.0现已发布.我刚刚更新了我的ADT插件并下载了4.0 SDK.但是当我尝试为Android 4.0 创建AVD时,Eclipse告诉我'无法为ABI armeabi找到'userdata.img'文件以复制到AVD文件夹中'.

我发现d:\android-sdk-windows\platforms\android-14缺少其他版本的'images'文件夹.此文件夹可能具有创建AVD应具有的"userdata.img".

我应该在哪里获得'userdata.img',以及如何为Android 4.0创建AVD?

android android-virtual-device

350
推荐指数
5
解决办法
16万
查看次数

如何使通知意图恢复而不是制定新的意图?

我在这里有一个简单的webview活动,加载后它会自动显示正在进行的通知.我们的想法是,人们可以远离此活动,并通过下拉菜单并选择它,从他们想要的任何屏幕再次快速访问它.然后,当他们想要时,他们可以通过点击菜单按钮并点击退出来关闭通知,然后清除通知.一切正常.但是,当按下通知时,它会启动活动的新实例.我需要更改什么才能看到活动是否尚未被销毁,我可以回调用该实例(恢复它),因此不需要再次加载它,也不需要在我的堆栈中添加其他活动.有任何想法吗?任何帮助将不胜感激.

package com.my.app;

import com.flurry.android.FlurryAgent;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent; 
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.webkit.CookieSyncManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

public class Chat extends Activity { 
    private ProgressDialog progressBar;
    public WebView webview;
    private static final String TAG = "Main";

    private NotificationManager mNotificationManager;
    private int SIMPLE_NOTFICATION_ID;

    @Override
    public void onStart() {
       super.onStart();
       CookieSyncManager.getInstance().sync();
       FlurryAgent.onStartSession(this, "H9QGMRC46IPXB43GYWU1");
    }

    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); …
Run Code Online (Sandbox Code Playgroud)

resume notifications android android-intent android-activity

39
推荐指数
3
解决办法
5万
查看次数

Android的Nine-patch drawables中红色的含义

根据Android文档,我们知道左侧和顶部黑线定义了可伸展区域,而底部和右侧行定义了内容区域.

这很容易理解,但我在android-17框架中找到了名为textfield_activated_holo_dark.9.png的图片.左下角,右下角和右上角的红色是什么目的?

在此输入图像描述

android nine-patch

21
推荐指数
2
解决办法
5417
查看次数

使用Google Play服务10.2.98,API 19中的Firebase性能崩溃

本周我开始在我的新应用中测试新的Firebase性能.一旦我将Firebase用于Auth和DB等其他功能,我已经将所有软件包更新为10.2.6 Firebase版本并遵循所有预先请求的说明.

minAPI是19.

我的问题是App在运行Android 4.4.1的真实Galaxy Duos设备中仅在API 19中与Google Play Services 10.2.98崩溃.当App启动时,它无法在设备中找到firebase-perf.

它只发生在这个软件包和其他设备和更高版本中,一切都很好,我可以在Firebase Performance Dashboard中看到数据.

提示 ?

Stacktrace下面

问候,

Process: com.mobilecodelabs.fb.trampo, PID: 2727
java.lang.RuntimeException: Unable to get provider com.google.firebase.perf.provider.FirebasePerfProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.perf.provider.FirebasePerfProvider" on path: DexPathList[[zip file "/data/app/com.mobilecodelabs.fb.trampo-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.mobilecodelabs.fb.trampo-2, /vendor/lib, /system/lib]]
    at android.app.ActivityThread.installProvider(ActivityThread.java:4793)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4385)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325)
    at android.app.ActivityThread.access$1500(ActivityThread.java:135)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5017)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.perf.provider.FirebasePerfProvider" on path: DexPathList[[zip file "/data/app/com.mobilecodelabs.fb.trampo-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.mobilecodelabs.fb.trampo-2, /vendor/lib, …
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-performance

11
推荐指数
1
解决办法
1590
查看次数

LocationManager和LocationClient一起获取用户位置

我只需要获取用户位置.优选地,确切的位置,但如果不可能,粗略的位置将是好的.

根据文件:

LocationClient.getLastLocation()

Returns the best most recent location currently available.

LocationManager.getLastKnownLocation(字符串)

Returns a Location indicating the data from the last known location fix obtained from the given provider.

如果我的理解是对的,那么前者会给我一个非常好的结果(或者有时为空),而后者会给我一个很少会为空的结果.

这是我的代码(简化)

locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationClient = new LocationClient(this, this, this);

@Override
public void onConnected(Bundle dataBundle) {
    setUserLocation();
}

private void setUserLocation() {
    myLocation = locationClient.getLastLocation();

    if (myLocation == null) {
        myLocation = locationManager.getLastKnownLocation(locationManager.getBestProvider(new Criteria(), false));
        if (myLocation == null) {
            //I give up, just set the map somewhere …
Run Code Online (Sandbox Code Playgroud)

android location

8
推荐指数
1
解决办法
4836
查看次数

android蓝牙连接错误(读取失败的套接字可能关闭或超时)

我想从Android设备中的应用程序连接到远程设备(配对).远程设备是HC-05模块.
我的代码是:

UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); //Standard SerialPortService ID

try {
    mSocket = MyDevice.createRfcommSocketToServiceRecord(uuid);
} catch (IOException e) {
    Toast.makeText(this, "S", Toast.LENGTH_SHORT).show();
}  

ba.cancelDiscovery();

try {
    mSocket.connect();
} catch (IOException e){
    Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();

    Log.e("YOUR_APP_LOG_TAG1", "I got an error", e);
}

try {
    mOutputStream = mSocket.getOutputStream();
    mInputStream = mSocket.getInputStream();
} catch (IOException e) {
    Toast.makeText(this, "io", Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)

但我在行mSocket.connect()中遇到错误.

错误:

读取失败的套接字可能会关闭或超时读取ret

请帮忙.

android bluetooth arduino

8
推荐指数
1
解决办法
8573
查看次数

在Android VideoView上绘制叠加层(HUD)?

我有一个自定义视图,绘制HUD:

HUD

这是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <VideoView
        android:id="@+id/videoView1"
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <com.widgets.HUD
            android:id="@+id/hud"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.hud_fragment, container, false);

    frameLayout = (FrameLayout) view.findViewById(R.id.frameLayout);

    hudWidget = (HUD) view.findViewById(R.id.hudWidget);

    videoView = (VideoView) view.findViewById(R.id.videoView1);
    videoView.setVideoURI(Uri.parse("http://88.150.210.138:5001/spor"));
    videoView.start();

    frameLayout.removeView(hudWidget);
    frameLayout.addView(hudWidget);
    hudWidget.bringToFront();

    return view;
}
Run Code Online (Sandbox Code Playgroud)

一旦视频开始播放,我就会在我的VideoView上播放RTSP流,如下所示:

HUD上的视频

如何强制HUD在VideoView上绘制?HUD extends SurfaceView

项目

  • 我正在尝试添加VideoView的项目是DroidPlanner您可以尝试克隆并查看问题.(需要手动添加VideoView,因为它不在repo中).

android rtsp video-streaming ondraw android-videoview

7
推荐指数
1
解决办法
6153
查看次数

获取java.io.IOException:读取失败,套接字可能关闭或在BluetoothSocket.connect()上超时

我正在尝试编写一个代码,该代码仅连接到运行Android 4.4 KitKat的Nexus 7上的(现在)配对设备.无论我尝试过多少东西,我仍然会遇到这个错误.这是我尝试过的最后一个代码,它似乎正在做我见过人们报告成功的所有内容.

谁能指出我做错了什么?

BluetoothManager bluetoothManager =
            (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
BluetoothAdapter adapter = bluetoothManager.getAdapter();//BluetoothAdapter.getDefaultAdapter();
if (!adapter.isEnabled()) {
    Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
    startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
BluetoothDevice bt = adapter.getBondedDevices().iterator().next();
BluetoothDevice actual = adapter.getRemoteDevice(bt.getAddress());
String str = "";
for(BluetoothDevice bd : adapter.getBondedDevices()) {
    str += bd.getName() + "\n";
}
str+= actual;

textView.setText(str);
BluetoothSocket socket = actual.createInsecureRfcommSocketToServiceRecord(MY_UUID);
adapter.cancelDiscovery();
socket.connect();
PrintWriter out = new PrintWriter(socket.getOutputStream());
out.print(message);
out.flush();
Run Code Online (Sandbox Code Playgroud)

java android bluetooth

5
推荐指数
1
解决办法
8877
查看次数

BluetoothServerSocket接受失败并抛出IOException

我有一个支持OBEX对象推送配置文件的设备,此配置文件基于串行端口配置文件.我的猜测是我可以使用Android蓝牙聊天示例将此设备连接到我的Android手机.但是我遇到了一个问题,关于socket.accept()android SDK中的功能.我尝试完成将手机连接到此设备,如下所示:

adapter = BluetoothAdapter.getDefaultAdapter(); 
device = adapter.getRemoteDevice("00:1B:DC:0F:EC:7E");

AcceptThread = new AcceptThread(true, adapter, device);
AcceptThread.start(); 
Run Code Online (Sandbox Code Playgroud)

AcceptThread中的构造函数编码如下:

public AcceptThread(boolean secure, BluetoothAdapter adapter, BluetoothDevice device) {
    BluetoothServerSocket tmp = null;
    this.adapter = adapter;
    this.device = device;

    // Create a new listening server socket
    try {
        tmp = adapter.listenUsingInsecureRfcommWithServiceRecord(device.getName(), UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));
    } catch (Exception e) {
        Log.e(TAG, ".AcceptThread # listen() failed", e);
    } 
    mmServerSocket = tmp;
}
Run Code Online (Sandbox Code Playgroud)

问题是当我尝试connect()按照我之前说过做的时候

public void run() {
    BluetoothSocket socket = null;

    // Listen to the …
Run Code Online (Sandbox Code Playgroud)

android bluetooth

3
推荐指数
1
解决办法
7674
查看次数