- import android.bluetooth.BluetoothAdapter;
- import android.bluetooth.BluetoothDevice;
- import android.bluetooth.BluetoothServerSocket;
- import android.bluetooth.BluetoothSocket;
- import android.content.Intent;
- import android.graphics.Bitmap;
- import android.net.Uri;
- import android.provider.MediaStore;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.ImageView;
- import android.widget.Toast;
- import java.io.IOException;
- import java.util.UUID;
- public class MainActivity extends AppCompatActivity {
- private EditText etName;
- private Button btnChangeName, btnAddPhoto, btnStartServer, btnStartClient, btnSend;
- private ImageView ivProfile;
- private BluetoothAdapter bluetoothAdapter;
- private BluetoothDevice device;
- private BluetoothServerSocket serverSocket;
- private BluetoothSocket socket;
- private static final int PICK_IMAGE = 1;
- private static final int REQUEST_ENABLE_BT = 0;
- private final UUID uuid = UUID.fromString("3e14d6a3-6dde-4ee2-86d7-619e99b38345");
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- etName = (EditText) findViewById(R.id.etName);
- btnChangeName = (Button) findViewById(R.id.btnChangeName);
- btnAddPhoto = (Button) findViewById(R.id.btnAddPhoto);
- ivProfile = (ImageView) findViewById(R.id.ivProfile);
- btnStartServer = (Button) findViewById(R.id.btnStartServer);
- btnStartClient = (Button) findViewById(R.id.btnStartClient);
- btnSend = (Button) findViewById(R.id.btnSend);
- bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
- if (bluetoothAdapter == null) {
- Toast.makeText(this, "Bluetooth not supported", Toast.LENGTH_SHORT).show();
- }
- btnChangeName.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String name = etName.getText().toString();
- if (name.isEmpty()) {
- Toast.makeText(MainActivity.this, "Enter a valid name", Toast.LENGTH_SHORT).show();
- } else {
- // Change the name of the user
- }
- }
- });
- btnAddPhoto.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
[text] Код блютуз чат
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: