小编Nav*_*kar的帖子

在6.0.1中搜索附近的蓝牙

我正在使用一个搜索附近蓝牙的应用程序.我使用下面的代码,它在5.0中找到它返回附近的蓝牙设备,但是当我在6.0.1中测试时BluetoothDevice.ACTION_FOUND没有被调用,只有BluetoothAdapter.ACTION_DISCOVERY_STARTEDBluetoothAdapter.ACTION_DISCOVERY_FINISHED被调用.

@Override
protected void onCreate(Bundle savedInstanceState) {
    BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    bluetoothAdapter = bluetoothManager.getAdapter();
    Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
    discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION,0);
    startActivity(discoverableIntent);
}
private final BroadcastReceiver bReciever = new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        System.out.println(action);
        if (BluetoothDevice.ACTION_FOUND.equals(action)) {
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            System.out.println(device);
        }
    }
};
public void onSearch(View v){
    if (bluetoothAdapter.isDiscovering()) {
        bluetoothAdapter.cancelDiscovery();
    }
    System.out.println(bluetoothAdapter.startDiscovery());
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(BluetoothDevice.ACTION_FOUND);
    intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
    intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    registerReceiver(bReciever, intentFilter); …
Run Code Online (Sandbox Code Playgroud)

android bluetooth

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

java.lang.IllegalArgumentException:索引59处查询中的非法字符

我在做什么: 我正在尝试在android中进行反向地理编码

我收到错误:: java.lang.IllegalArgumentException:索引59的查询中出现非法字符:http://maps.google.com/maps/api/geocode/json? address = Agram,Bengaluru,Karnataka,India&sensor = false

注意:该请求在浏览器中获得了json响应,但不是来自我的下面的类

这一行给出了这个错误::

HttpGet httpget = new HttpGet(url);
Run Code Online (Sandbox Code Playgroud)

JSONfunctions.java

public class JSONfunctions {

    public static JSONObject getJSONfromURL(String url) {
        InputStream is = null;
        String result = "";
        JSONObject jArray = null;

        // Download JSON data from URL
        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpGet httpget = new HttpGet(url);

            HttpResponse response = httpclient.execute(httpget);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();

        } catch (Exception e) {
            Log.e("log_tag", "Error in …
Run Code Online (Sandbox Code Playgroud)

java android json google-maps

4
推荐指数
2
解决办法
2万
查看次数

Android LMK 和 Linux OOM 有什么区别

我知道这Android LMK是基于Linux OOM,但为什么谷歌要开发一种新算法(LMK)?LMK 比原来的 OOM 好吗?还是有其他技术原因?

android memory-management

4
推荐指数
1
解决办法
1521
查看次数

如何在firebase存储上下载图像?

我想firebase在 android 应用程序的存储中下载图像。

这是我的形象

在此处输入图片说明

我试试这个,但它不起作用

storageRef.child("1/1.jpg").getDownloadUrl().getResult(); 
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-storage

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

GridLayoutManager 自定义

我想知道是否有办法gridlayoutmanager在 android 中自定义以具有像此草图这样的水平布局: 在此处输入图片说明

我尝试了一些在 Github 中找到的布局管理器,但没有一个可以帮助我实现这种布局管理器。

像这样:

public class CustomLayoutManager extends StaggeredGridLayoutManager {
public CustomLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
}

public CustomLayoutManager(int spanCount, int orientation) {
    super(spanCount, orientation);
}

@Override
public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state, int widthSpec, int heightSpec) {
    super.onMeasure(recycler, state, widthSpec, heightSpec);
}

@Override
public void setSpanCount(int spanCount) {
    super.setSpanCount(spanCount);
}}
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激谢谢

android layout-manager gridlayoutmanager staggeredgridlayout

2
推荐指数
1
解决办法
2461
查看次数

如何在android中禁用未来的日期选择器

我是android的新手如何在日期选择器中禁用未来日期,我在堆栈中尝试了许多代码,但它无法帮助.任何人都帮我请求.

看看代码

public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.daty);



                click=(ImageView)findViewById(R.id.click);


                hdate=(TextView)findViewById(R.id.hdate);

                timeStamp = new SimpleDateFormat("dd/MM/yyyy").format(new Date(System.currentTimeMillis()));


                hdate.setText(timeStamp);


                final Calendar myCalendar = Calendar.getInstance();

       // listener for date picker        
                final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {

                    @Override
                    public void onDateSet(DatePicker view, int year, int monthOfYear,
                            int dayOfMonth) {
                        // TODO Auto-generated method stub
                        myCalendar.set(Calendar.YEAR, year);
                        myCalendar.set(Calendar.MONTH, monthOfYear);
                        myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                        updateLabel();
                    }

                    private void updateLabel() {
                        // TODO Auto-generated method stub

                        String myFormat = "dd/MM/yyyy";
                        SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
                        hdate.setText(sdf.format(myCalendar.getTime()));


                    } …
Run Code Online (Sandbox Code Playgroud)

android date picker

-2
推荐指数
1
解决办法
7993
查看次数