;package [Link].
womensecurity6
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
;import [Link]
{ public class CommsActivity extends AppCompatActivity
public BluetoothAdapter BTAdapter =
;)([Link]
;"private static final String TAG = "CommsActivity
;BluetoothSocket mmSocket
;BluetoothDevice mmDevice
////
;FirebaseDatabase firebaseDatabase
;DatabaseReference ref1,ref2,ref3
;FirebaseUser user
;FirebaseAuth auth
;String id
;String eContact
;Double latitude,longitude
;TextView t1,t2,t3
;ImageView imageViewCAM
////
Override@
{ )protected void onCreate(Bundle savedInstanceState
;)[Link](savedInstanceState
;)setContentView([Link].activity_comms
;)t1=(TextView)findViewById([Link]
;)t2=(TextView)findViewById([Link]
;)t3=(TextView)findViewById([Link]
;)imageViewCAM = (ImageView)findViewById([Link]
;)(auth=[Link]
;)(user=[Link]
;)(id=[Link]
;)(firebaseDatabase=[Link]
ref1
)"=[Link]("Users").child(id).child("econtact
;
ref2
;)"=[Link]("Users").child(id).child("lat
ref3
;)"=[Link]("Users").child(id).child("lng
read Econtacts//
{ )([Link](new ValueEventListener
Override@
public void onDataChange(@NonNull DataSnapshot
{ )dataSnapshot
;)eContact = [Link]([Link]
;)[Link](eContact
}
Override@
public void onCancelled(@NonNull DatabaseError
{ )databaseError
}
;)}
read Lat//
{ )([Link](new ValueEventListener
Override@
public void onDataChange(@NonNull DataSnapshot
{ )dataSnapshot
;)latitude = [Link]([Link]
;)""+[Link](latitude
}
Override@
public void onCancelled(@NonNull DatabaseError
{ )databaseError
}
;)}
read Lng//
{ )([Link](new ValueEventListener
Override@
public void onDataChange(@NonNull DataSnapshot
{ )dataSnapshot
;)longitude = [Link]([Link]
;)""+[Link](longitude
}
Override@
public void onCancelled(@NonNull DatabaseError
{ )databaseError
}
;)}
BluetoothAdapter mBluetoothAdapter =
;)([Link]
;)(final Intent intent = getIntent
final String address =
;)[Link](BluetoothActivity.EXTRA_ADDRESS
;)Button connect = (Button) findViewById([Link]
{ )([Link](new [Link]
{ )public void onClick(View v
final BluetoothDevice device =
;)[Link](address
{ try
;)(new ConnectThread(device).start
{ )catch (IOException e }
;)([Link]
}
}
;)}
{ ))(if (![Link]
Intent enableBluetooth = new
;)Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE
;)startActivityForResult(enableBluetooth, 0
}
}
Override@
{ )(protected void onStop
;)([Link]
{ try
;)([Link]
{ )catch (IOException e }
;)([Link]
}
}
connected class //
{ public class ConnectThread extends Thread
private ConnectThread(BluetoothDevice device) throws
{ IOException
;BluetoothSocket tmp = null
;mmDevice = device
{ try
UUID uuid =
;)"[Link]("94f39d29-7d6d-437d-973b-fba39e49d4ee
tmp =
;)[Link](uuid
{ )catch (IOException e }
;)Log.e(TAG, "Socket's create() method failed", e
}
;mmSocket = tmp
;)([Link]
{ try
;)([Link]
{ )catch (IOException connectException }
;)"!Log.v(TAG, "Connection exception
{ try
;)([Link]
{ )catch (IOException closeException }
}
}
;)(send
}
{ public void send() throws IOException
;"String msg = "connect
OutputStream mmOutputStream =
;)([Link]
;))([Link]([Link]
;)(receive
}
{ public void receive() throws IOException
;)(InputStream mmInputStream = [Link]
;]byte[] buffer = new byte[8192
;int bytes
{ try
;)bytes = [Link](buffer
String readMessage = new String(buffer, 0, bytes); // to
read message
to read an image //
*/
{ )if (bytes != -1
.ensure DATAMAXSIZE Byte is read//
;int byteNo2 = bytes
;int bufferSize = 7340
{)while(byteNo2 != bufferSize
;bufferSize = bufferSize - byteNo2
byteNo2 =
;)[Link](buffer,bytes,bufferSize
{)if(byteNo2 == -1
;break
}
;bytes = bytes+byteNo2
}
}
/*
end of requirements to read an image ///
to load an image into an Image view ===> convert it to //
bitmap
*/
{))"if([Link]("A
;)(SmsManager sm = [Link]
[Link](eContact, null, "I am in danger
please help me ,,, My Location is :" +
"[Link]
;)null, null
}
/*
{else//
Bitmap bm1 =
;)[Link](buffer,0,[Link]
;)[Link](bm1
;)[Link]().load(readMessage).into(imageViewCAM//
} //
;)Log.d(TAG, "Received: " + readMessage
;)TextView status = (TextView) findViewById([Link]
;) [Link]("Button : "+ readMessage
;)([Link]
{ )catch (IOException e }
;)"!Log.e(TAG, "Problems occurred
;return
}
}
end of connectThread class // }