小编use*_*835的帖子

如何以编程方式将android设备连接到"WPA2 PSK"安全wifi热点网络?

在我的Android应用程序中,我正在尝试将我的Android设备连接到"WPA2-PSK"安全连接,经过大量搜索,我编写了以下代码 -

if (securityMode.equalsIgnoreCase("WPA2")) // WPA2
                {

                   wifiConfiguration.SSID = "\"" + networkSSID + "\"";
                    wifiConfiguration.preSharedKey = "\"" + networkPass + "\"";
                    wifiConfiguration.status = WifiConfiguration.Status.ENABLED;
                    wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
                    wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
                    wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
                    wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
                    wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
                    wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
                    wifiManager.setWifiEnabled(true);
                    wifiManager.saveConfiguration();
                    int added = wifiManager.addNetwork(wifiConfiguration);
                    System.out.println("added network: " + added);
                    boolean enabled = wifiManager.enableNetwork(added, true);
                    System.out.println("enableNetwork returned: " + enabled);                   

                }
Run Code Online (Sandbox Code Playgroud)

上面的代码执行正常(没有任何错误),但不知道为什么,连接没有建立.请帮忙.谢谢.!

android

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

实现自定义列表视图的复选框

我已经编写了代码来从数据库中获取值并将这些值绑定到listview.因为我现在根据需要使用了自定义列表视图我想要列表中每个项目的复选框.如何做到这一点

image=(ImageView)findViewById(R.id.image);
        note=(ImageButton)findViewById(R.id.note);
        tick=(ImageButton)findViewById(R.id.tick);
        cross=(ImageButton)findViewById(R.id.cross);
        Intent intent = getIntent();
        Bitmap photo = (Bitmap) intent.getParcelableExtra("photooo");
        image.setImageBitmap(photo);
        if(photo!=null)
        {
            dbHelper = new RecordsDbAdapter(this);
            dbHelper.open();
            displayListView();
        }

    }
    private void displayListView() {
        Cursor cursor = dbHelper.fetchAllRecords();
        String[] columns = new String[] {
                RecordsDbAdapter.KEY_NAME,
                RecordsDbAdapter.KEY_BIRTHDAY,

        };
        int[] to = new int[] {
                R.id.name,
                R.id.birthdate,
        };
        dataAdapter = new SimpleCursorAdapter(
                this, R.layout.row,
                cursor,
                columns,
                to);
        ListView listView = (ListView) findViewById(R.id.list);
        listView.setAdapter(dataAdapter);
    }
}
Run Code Online (Sandbox Code Playgroud)

database checkbox android listview

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

将图像保存在SD卡中

我已经编写了编辑图像的代码,现在我想将该编辑的图像保存在SD卡中

image=(ImageView)findViewById(R.id.image);
        Intent intent = getIntent();
        File sdCardDirectory = Environment.getExternalStorageDirectory();
        photo = (Bitmap) intent.getParcelableExtra("photoo");
        image.setImageBitmap(photo);
Run Code Online (Sandbox Code Playgroud)

android sd-card

0
推荐指数
1
解决办法
6429
查看次数

在文本文件中获取换行符

我的文本文件存储在assets文件夹中,我的要求是在textview中显示内容.如果文本文件中没有空格存储在assets文件夹中,我可以访问内容.如果我在文本中放置空格文件,然后我无法得到空间后的内容.如何实现这意味着逐点显示内容.例如我的文本文件如下

一)Americab)Africac)印度

我希望输出为

a)美国

b)非洲

c)印度

Here is my code to access the text file from assest folder which I am getting.

InputStream in = this.getAssets().open("detailtext.txt");
            BufferedReader reader = new BufferedReader(new InputStreamReader(in));
            line = reader.readLine();
Run Code Online (Sandbox Code Playgroud)

android assets text-files textview

0
推荐指数
1
解决办法
782
查看次数

标签 统计

android ×4

assets ×1

checkbox ×1

database ×1

listview ×1

sd-card ×1

text-files ×1

textview ×1