Codes bluetooth email camera - converted
Codes bluetooth email camera - converted
send email code :- System.err.println("Error sending email: " + e.getMessage()); Bluetooth code :- send email code :- System.err.println("Error sending email: " + e.getMessage()); Bluetooth code :- send email code :- System.err.println("Error sending email: " + e.getMessage());
import javax.bluetooth.*; import java.util.Properties; } import javax.bluetooth.*; import java.util.Properties; } import javax.bluetooth.*; import java.util.Properties; }
import javax.microedition.io.*; import javax.mail.*; } import javax.microedition.io.*; import javax.mail.*; } import javax.microedition.io.*; import javax.mail.*; }
import java.io.IOException; import javax.mail.internet.*; public static void main(String[] args) { import java.io.IOException; import javax.mail.internet.*; public static void main(String[] args) { import java.io.IOException; import javax.mail.internet.*; public static void main(String[] args) {
public class BluetoothExample { public class SendEmail { // Replace with recipient email, subject and message body public class BluetoothExample { public class SendEmail { // Replace with recipient email, subject and message body public class BluetoothExample { public class SendEmail { // Replace with recipient email, subject and message body
public static void main(String[] args) { private static final String SMTP_HOST = "smtp.gmail.com"; String toEmail = "[email protected]"; public static void main(String[] args) { private static final String SMTP_HOST = "smtp.gmail.com"; String toEmail = "[email protected]"; public static void main(String[] args) { private static final String SMTP_HOST = "smtp.gmail.com"; String toEmail = "[email protected]";
try { private static final String SMTP_PORT = "587"; String subject = "Test Email from Java"; try { private static final String SMTP_PORT = "587"; String subject = "Test Email from Java"; try { private static final String SMTP_PORT = "587"; String subject = "Test Email from Java";
final Object inquiryCompletedEvent = new Object(); private static final String USERNAME = "[email protected]"; String body = "Hello!\nThis is a simple email sent from Java."; final Object inquiryCompletedEvent = new Object(); private static final String USERNAME = "[email protected]"; String body = "Hello!\nThis is a simple email sent from Java."; final Object inquiryCompletedEvent = new Object(); private static final String USERNAME = "[email protected]"; String body = "Hello!\nThis is a simple email sent from Java.";
DiscoveryListener listener = new DiscoveryListener() { private static final String PASSWORD = "your_email_password_or_app_password"; sendEmail(toEmail, subject, body); DiscoveryListener listener = new DiscoveryListener() { private static final String PASSWORD = "your_email_password_or_app_password"; sendEmail(toEmail, subject, body); DiscoveryListener listener = new DiscoveryListener() { private static final String PASSWORD = "your_email_password_or_app_password"; sendEmail(toEmail, subject, body);
public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { public static void sendEmail(String toEmail, String subject, String body) { } public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { public static void sendEmail(String toEmail, String subject, String body) { } public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { public static void sendEmail(String toEmail, String subject, String body) { }
try { Properties props = new Properties(); } try { Properties props = new Properties(); } try { Properties props = new Properties(); }
System.out.println("Device found: " + btDevice.getFriendlyName(false)); props.put("mail.smtp.auth", "true"); </content> System.out.println("Device found: " + btDevice.getFriendlyName(false)); props.put("mail.smtp.auth", "true"); </content> System.out.println("Device found: " + btDevice.getFriendlyName(false)); props.put("mail.smtp.auth", "true"); </content>
} catch (IOException e) { props.put("mail.smtp.starttls.enable", "true"); </create_file> } catch (IOException e) { props.put("mail.smtp.starttls.enable", "true"); </create_file> } catch (IOException e) { props.put("mail.smtp.starttls.enable", "true"); </create_file>
System.out.println("Device found: " + btDevice.getBluetoothAddress()); props.put("mail.smtp.host", SMTP_HOST); System.out.println("Device found: " + btDevice.getBluetoothAddress()); props.put("mail.smtp.host", SMTP_HOST); System.out.println("Device found: " + btDevice.getBluetoothAddress()); props.put("mail.smtp.host", SMTP_HOST);
} Session session = Session.getInstance(props, new Authenticator() { } Session session = Session.getInstance(props, new Authenticator() { } Session session = Session.getInstance(props, new Authenticator() {
public void inquiryCompleted(int discType) { protected PasswordAuthentication getPasswordAuthentication() { public void inquiryCompleted(int discType) { protected PasswordAuthentication getPasswordAuthentication() { public void inquiryCompleted(int discType) { protected PasswordAuthentication getPasswordAuthentication() {
synchronized (inquiryCompletedEvent) { return new PasswordAuthentication(USERNAME, PASSWORD); synchronized (inquiryCompletedEvent) { return new PasswordAuthentication(USERNAME, PASSWORD); synchronized (inquiryCompletedEvent) { return new PasswordAuthentication(USERNAME, PASSWORD);
public void serviceSearchCompleted(int transID, int respCode) {} Message message = new MimeMessage(session); public void serviceSearchCompleted(int transID, int respCode) {} Message message = new MimeMessage(session); public void serviceSearchCompleted(int transID, int respCode) {} Message message = new MimeMessage(session);
public void servicesDiscovered(int transID, ServiceRecord[] records) {} message.setFrom(new InternetAddress(USERNAME)); public void servicesDiscovered(int transID, ServiceRecord[] records) {} message.setFrom(new InternetAddress(USERNAME)); public void servicesDiscovered(int transID, ServiceRecord[] records) {} message.setFrom(new InternetAddress(USERNAME));
DiscoveryAgent agent = LocalDevice.getLocalDevice().getDiscoveryAgent(); Message.RecipientType.TO, InternetAddress.parse(toEmail)); DiscoveryAgent agent = LocalDevice.getLocalDevice().getDiscoveryAgent(); Message.RecipientType.TO, InternetAddress.parse(toEmail)); DiscoveryAgent agent = LocalDevice.getLocalDevice().getDiscoveryAgent(); Message.RecipientType.TO, InternetAddress.parse(toEmail));
} System.out.println("Email sent successfully to " + toEmail); } System.out.println("Email sent successfully to " + toEmail); } System.out.println("Email sent successfully to " + toEmail);
} catch (BluetoothStateException | InterruptedException e) { } catch (MessagingException e) { } catch (BluetoothStateException | InterruptedException e) { } catch (MessagingException e) { } catch (BluetoothStateException | InterruptedException e) { } catch (MessagingException e) {
1 2 3 1 2 3 1 2 3
Sms code :- Current location code :- String inputLine; Sms code :- Current location code :- String inputLine; Sms code :- Current location code :- String inputLine;
import com.twilio.Twilio; import java.awt.HeadlessException; StringBuilder response = new StringBuilder(); import com.twilio.Twilio; import java.awt.HeadlessException; StringBuilder response = new StringBuilder(); import com.twilio.Twilio; import java.awt.HeadlessException; StringBuilder response = new StringBuilder();
import com.twilio.rest.api.v2010.account.Message; import javax.swing.JFrame; while ((inputLine = in.readLine()) != null) { import com.twilio.rest.api.v2010.account.Message; import javax.swing.JFrame; while ((inputLine = in.readLine()) != null) { import com.twilio.rest.api.v2010.account.Message; import javax.swing.JFrame; while ((inputLine = in.readLine()) != null) {
import com.twilio.type.PhoneNumber; import javax.swing.JLabel; response.append(inputLine); import com.twilio.type.PhoneNumber; import javax.swing.JLabel; response.append(inputLine); import com.twilio.type.PhoneNumber; import javax.swing.JLabel; response.append(inputLine);
public class SendSms { import java.io.InputStreamReader; in.close(); public class SendSms { import java.io.InputStreamReader; in.close(); public class SendSms { import java.io.InputStreamReader; in.close();
// Replace these with your Twilio account details import java.net.HttpURLConnection; // Replace these with your Twilio account details import java.net.HttpURLConnection; // Replace these with your Twilio account details import java.net.HttpURLConnection;
public static final String ACCOUNT_SID = "YOUR_ACCOUNT_SID"; import java.net.URL; JSONObject json = new JSONObject(response.toString()); public static final String ACCOUNT_SID = "YOUR_ACCOUNT_SID"; import java.net.URL; JSONObject json = new JSONObject(response.toString()); public static final String ACCOUNT_SID = "YOUR_ACCOUNT_SID"; import java.net.URL; JSONObject json = new JSONObject(response.toString());
public static final String AUTH_TOKEN = "YOUR_AUTH_TOKEN"; import org.json.JSONObject; if ("success".equals(json.getString("status"))) { public static final String AUTH_TOKEN = "YOUR_AUTH_TOKEN"; import org.json.JSONObject; if ("success".equals(json.getString("status"))) { public static final String AUTH_TOKEN = "YOUR_AUTH_TOKEN"; import org.json.JSONObject; if ("success".equals(json.getString("status"))) {
result = "City: " + json.getString("city") + ", Region: " + json.getString("regionName") + result = "City: " + json.getString("city") + ", Region: " + json.getString("regionName") + result = "City: " + json.getString("city") + ", Region: " + json.getString("regionName") +
public static void main(String[] args) { public class UserLocation extends JFrame { ", Country: " + json.getString("country") + "<br>Latitude: " + json.getDouble("lat") + public static void main(String[] args) { public class UserLocation extends JFrame { ", Country: " + json.getString("country") + "<br>Latitude: " + json.getDouble("lat") + public static void main(String[] args) { public class UserLocation extends JFrame { ", Country: " + json.getString("country") + "<br>Latitude: " + json.getDouble("lat") +
// Initialize the Twilio client public UserLocation() throws HeadlessException { ", Longitude: " + json.getDouble("lon"); // Initialize the Twilio client public UserLocation() throws HeadlessException { ", Longitude: " + json.getDouble("lon"); // Initialize the Twilio client public UserLocation() throws HeadlessException { ", Longitude: " + json.getDouble("lon");
Twilio.init(ACCOUNT_SID, AUTH_TOKEN); setTitle("User Current Location"); } Twilio.init(ACCOUNT_SID, AUTH_TOKEN); setTitle("User Current Location"); } Twilio.init(ACCOUNT_SID, AUTH_TOKEN); setTitle("User Current Location"); }
// Your Twilio phone number (or sender ID) setSize(400, 200); } catch (Exception e) { // Your Twilio phone number (or sender ID) setSize(400, 200); } catch (Exception e) { // Your Twilio phone number (or sender ID) setSize(400, 200); } catch (Exception e) {
String fromPhone = "+12345678901"; // Replace with your Twilio number setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); result = "Error retrieving location"; String fromPhone = "+12345678901"; // Replace with your Twilio number setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); result = "Error retrieving location"; String fromPhone = "+12345678901"; // Replace with your Twilio number setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); result = "Error retrieving location";
// Recipient phone number setLocationRelativeTo(null); } // Recipient phone number setLocationRelativeTo(null); } // Recipient phone number setLocationRelativeTo(null); }
String toPhone = "+10987654321"; // Replace with recipient's phone number return result; String toPhone = "+10987654321"; // Replace with recipient's phone number return result; String toPhone = "+10987654321"; // Replace with recipient's phone number return result;
// Message to send JLabel label = new JLabel("<html>Your Approximate Location:<br>" + location + "</html>"); public static void main(String[] args) { // Message to send JLabel label = new JLabel("<html>Your Approximate Location:<br>" + location + "</html>"); public static void main(String[] args) { // Message to send JLabel label = new JLabel("<html>Your Approximate Location:<br>" + location + "</html>"); public static void main(String[] args) {
String messageBody = "Hello from Java via Twilio!"; add(label); javax.swing.SwingUtilities.invokeLater(() -> { String messageBody = "Hello from Java via Twilio!"; add(label); javax.swing.SwingUtilities.invokeLater(() -> { String messageBody = "Hello from Java via Twilio!"; add(label); javax.swing.SwingUtilities.invokeLater(() -> {
// Send the SMS message } UserLocation app = new UserLocation(); // Send the SMS message } UserLocation app = new UserLocation(); // Send the SMS message } UserLocation app = new UserLocation();
Message message = Message.creator( public String getUserLocation() { app.setVisible(true); Message message = Message.creator( public String getUserLocation() { app.setVisible(true); Message message = Message.creator( public String getUserLocation() { app.setVisible(true);
new PhoneNumber(toPhone), String result = "Location not available"; }); new PhoneNumber(toPhone), String result = "Location not available"; }); new PhoneNumber(toPhone), String result = "Location not available"; });
messageBody) // Use ip-api.com to fetch user location based on IP } messageBody) // Use ip-api.com to fetch user location based on IP } messageBody) // Use ip-api.com to fetch user location based on IP }
.create(); String urlStr = "http://ip-api.com/json"; </content> .create(); String urlStr = "http://ip-api.com/json"; </content> .create(); String urlStr = "http://ip-api.com/json"; </content>
// Print the message SID (for reference) URL url = new URL(urlStr); </create_file> // Print the message SID (for reference) URL url = new URL(urlStr); </create_file> // Print the message SID (for reference) URL url = new URL(urlStr); </create_file>
System.out.println("SMS sent successfully. Message SID: " + message.getSid()); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); System.out.println("SMS sent successfully. Message SID: " + message.getSid()); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); System.out.println("SMS sent successfully. Message SID: " + message.getSid()); HttpURLConnection conn = (HttpURLConnection) url.openConnection();
} BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); } BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); } BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
4 5 6 4 5 6 4 5 6
public static void main(String[] args) { public static void main(String[] args) { public static void main(String[] args) {
VideoCapture camera = new VideoCapture(0); // 0 is the default camera VideoCapture camera = new VideoCapture(0); // 0 is the default camera VideoCapture camera = new VideoCapture(0); // 0 is the default camera
Mat frame = new Mat(); Mat frame = new Mat(); Mat frame = new Mat();
System.out.println("Error: Camera is not available."); System.out.println("Error: Camera is not available."); System.out.println("Error: Camera is not available.");
} } }
HighGui.imshow("Captured Image", frame); // Display the captured image HighGui.imshow("Captured Image", frame); // Display the captured image HighGui.imshow("Captured Image", frame); // Display the captured image
HighGui.waitKey(0); // Wait for a key press HighGui.waitKey(0); // Wait for a key press HighGui.waitKey(0); // Wait for a key press
} } }
camera.release(); // Release the camera camera.release(); // Release the camera camera.release(); // Release the camera
} } }
} } }
7 8 7 8 7 8
Bluetooth code :- send email code :- System.err.println("Error sending email: " + e.getMessage()); Bluetooth code :- send email code :- System.err.println("Error sending email: " + e.getMessage()); Bluetooth code :- send email code :- System.err.println("Error sending email: " + e.getMessage());
import javax.bluetooth.*; import java.util.Properties; } import javax.bluetooth.*; import java.util.Properties; } import javax.bluetooth.*; import java.util.Properties; }
import javax.microedition.io.*; import javax.mail.*; } import javax.microedition.io.*; import javax.mail.*; } import javax.microedition.io.*; import javax.mail.*; }
import java.io.IOException; import javax.mail.internet.*; public static void main(String[] args) { import java.io.IOException; import javax.mail.internet.*; public static void main(String[] args) { import java.io.IOException; import javax.mail.internet.*; public static void main(String[] args) {
public class BluetoothExample { public class SendEmail { // Replace with recipient email, subject and message body public class BluetoothExample { public class SendEmail { // Replace with recipient email, subject and message body public class BluetoothExample { public class SendEmail { // Replace with recipient email, subject and message body
public static void main(String[] args) { private static final String SMTP_HOST = "smtp.gmail.com"; String toEmail = "[email protected]"; public static void main(String[] args) { private static final String SMTP_HOST = "smtp.gmail.com"; String toEmail = "[email protected]"; public static void main(String[] args) { private static final String SMTP_HOST = "smtp.gmail.com"; String toEmail = "[email protected]";
try { private static final String SMTP_PORT = "587"; String subject = "Test Email from Java"; try { private static final String SMTP_PORT = "587"; String subject = "Test Email from Java"; try { private static final String SMTP_PORT = "587"; String subject = "Test Email from Java";
final Object inquiryCompletedEvent = new Object(); private static final String USERNAME = "[email protected]"; String body = "Hello!\nThis is a simple email sent from Java."; final Object inquiryCompletedEvent = new Object(); private static final String USERNAME = "[email protected]"; String body = "Hello!\nThis is a simple email sent from Java."; final Object inquiryCompletedEvent = new Object(); private static final String USERNAME = "[email protected]"; String body = "Hello!\nThis is a simple email sent from Java.";
DiscoveryListener listener = new DiscoveryListener() { private static final String PASSWORD = "your_email_password_or_app_password"; sendEmail(toEmail, subject, body); DiscoveryListener listener = new DiscoveryListener() { private static final String PASSWORD = "your_email_password_or_app_password"; sendEmail(toEmail, subject, body); DiscoveryListener listener = new DiscoveryListener() { private static final String PASSWORD = "your_email_password_or_app_password"; sendEmail(toEmail, subject, body);
public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { public static void sendEmail(String toEmail, String subject, String body) { } public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { public static void sendEmail(String toEmail, String subject, String body) { } public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { public static void sendEmail(String toEmail, String subject, String body) { }
try { Properties props = new Properties(); } try { Properties props = new Properties(); } try { Properties props = new Properties(); }
System.out.println("Device found: " + btDevice.getFriendlyName(false)); props.put("mail.smtp.auth", "true"); </content> System.out.println("Device found: " + btDevice.getFriendlyName(false)); props.put("mail.smtp.auth", "true"); </content> System.out.println("Device found: " + btDevice.getFriendlyName(false)); props.put("mail.smtp.auth", "true"); </content>
} catch (IOException e) { props.put("mail.smtp.starttls.enable", "true"); </create_file> } catch (IOException e) { props.put("mail.smtp.starttls.enable", "true"); </create_file> } catch (IOException e) { props.put("mail.smtp.starttls.enable", "true"); </create_file>
System.out.println("Device found: " + btDevice.getBluetoothAddress()); props.put("mail.smtp.host", SMTP_HOST); System.out.println("Device found: " + btDevice.getBluetoothAddress()); props.put("mail.smtp.host", SMTP_HOST); System.out.println("Device found: " + btDevice.getBluetoothAddress()); props.put("mail.smtp.host", SMTP_HOST);
} Session session = Session.getInstance(props, new Authenticator() { } Session session = Session.getInstance(props, new Authenticator() { } Session session = Session.getInstance(props, new Authenticator() {
public void inquiryCompleted(int discType) { protected PasswordAuthentication getPasswordAuthentication() { public void inquiryCompleted(int discType) { protected PasswordAuthentication getPasswordAuthentication() { public void inquiryCompleted(int discType) { protected PasswordAuthentication getPasswordAuthentication() {
synchronized (inquiryCompletedEvent) { return new PasswordAuthentication(USERNAME, PASSWORD); synchronized (inquiryCompletedEvent) { return new PasswordAuthentication(USERNAME, PASSWORD); synchronized (inquiryCompletedEvent) { return new PasswordAuthentication(USERNAME, PASSWORD);
public void serviceSearchCompleted(int transID, int respCode) {} Message message = new MimeMessage(session); public void serviceSearchCompleted(int transID, int respCode) {} Message message = new MimeMessage(session); public void serviceSearchCompleted(int transID, int respCode) {} Message message = new MimeMessage(session);
public void servicesDiscovered(int transID, ServiceRecord[] records) {} message.setFrom(new InternetAddress(USERNAME)); public void servicesDiscovered(int transID, ServiceRecord[] records) {} message.setFrom(new InternetAddress(USERNAME)); public void servicesDiscovered(int transID, ServiceRecord[] records) {} message.setFrom(new InternetAddress(USERNAME));
DiscoveryAgent agent = LocalDevice.getLocalDevice().getDiscoveryAgent(); Message.RecipientType.TO, InternetAddress.parse(toEmail)); DiscoveryAgent agent = LocalDevice.getLocalDevice().getDiscoveryAgent(); Message.RecipientType.TO, InternetAddress.parse(toEmail)); DiscoveryAgent agent = LocalDevice.getLocalDevice().getDiscoveryAgent(); Message.RecipientType.TO, InternetAddress.parse(toEmail));
} System.out.println("Email sent successfully to " + toEmail); } System.out.println("Email sent successfully to " + toEmail); } System.out.println("Email sent successfully to " + toEmail);
} catch (BluetoothStateException | InterruptedException e) { } catch (MessagingException e) { } catch (BluetoothStateException | InterruptedException e) { } catch (MessagingException e) { } catch (BluetoothStateException | InterruptedException e) { } catch (MessagingException e) {
1 2 3 1 2 3 1 2 3
Sms code :- Current location code :- String inputLine; Sms code :- Current location code :- String inputLine; Sms code :- Current location code :- String inputLine;
import com.twilio.Twilio; import java.awt.HeadlessException; StringBuilder response = new StringBuilder(); import com.twilio.Twilio; import java.awt.HeadlessException; StringBuilder response = new StringBuilder(); import com.twilio.Twilio; import java.awt.HeadlessException; StringBuilder response = new StringBuilder();
import com.twilio.rest.api.v2010.account.Message; import javax.swing.JFrame; while ((inputLine = in.readLine()) != null) { import com.twilio.rest.api.v2010.account.Message; import javax.swing.JFrame; while ((inputLine = in.readLine()) != null) { import com.twilio.rest.api.v2010.account.Message; import javax.swing.JFrame; while ((inputLine = in.readLine()) != null) {
import com.twilio.type.PhoneNumber; import javax.swing.JLabel; response.append(inputLine); import com.twilio.type.PhoneNumber; import javax.swing.JLabel; response.append(inputLine); import com.twilio.type.PhoneNumber; import javax.swing.JLabel; response.append(inputLine);
public class SendSms { import java.io.InputStreamReader; in.close(); public class SendSms { import java.io.InputStreamReader; in.close(); public class SendSms { import java.io.InputStreamReader; in.close();
// Replace these with your Twilio account details import java.net.HttpURLConnection; // Replace these with your Twilio account details import java.net.HttpURLConnection; // Replace these with your Twilio account details import java.net.HttpURLConnection;
public static final String ACCOUNT_SID = "YOUR_ACCOUNT_SID"; import java.net.URL; JSONObject json = new JSONObject(response.toString()); public static final String ACCOUNT_SID = "YOUR_ACCOUNT_SID"; import java.net.URL; JSONObject json = new JSONObject(response.toString()); public static final String ACCOUNT_SID = "YOUR_ACCOUNT_SID"; import java.net.URL; JSONObject json = new JSONObject(response.toString());
public static final String AUTH_TOKEN = "YOUR_AUTH_TOKEN"; import org.json.JSONObject; if ("success".equals(json.getString("status"))) { public static final String AUTH_TOKEN = "YOUR_AUTH_TOKEN"; import org.json.JSONObject; if ("success".equals(json.getString("status"))) { public static final String AUTH_TOKEN = "YOUR_AUTH_TOKEN"; import org.json.JSONObject; if ("success".equals(json.getString("status"))) {
result = "City: " + json.getString("city") + ", Region: " + json.getString("regionName") + result = "City: " + json.getString("city") + ", Region: " + json.getString("regionName") + result = "City: " + json.getString("city") + ", Region: " + json.getString("regionName") +
public static void main(String[] args) { public class UserLocation extends JFrame { ", Country: " + json.getString("country") + "<br>Latitude: " + json.getDouble("lat") + public static void main(String[] args) { public class UserLocation extends JFrame { ", Country: " + json.getString("country") + "<br>Latitude: " + json.getDouble("lat") + public static void main(String[] args) { public class UserLocation extends JFrame { ", Country: " + json.getString("country") + "<br>Latitude: " + json.getDouble("lat") +
// Initialize the Twilio client public UserLocation() throws HeadlessException { ", Longitude: " + json.getDouble("lon"); // Initialize the Twilio client public UserLocation() throws HeadlessException { ", Longitude: " + json.getDouble("lon"); // Initialize the Twilio client public UserLocation() throws HeadlessException { ", Longitude: " + json.getDouble("lon");
Twilio.init(ACCOUNT_SID, AUTH_TOKEN); setTitle("User Current Location"); } Twilio.init(ACCOUNT_SID, AUTH_TOKEN); setTitle("User Current Location"); } Twilio.init(ACCOUNT_SID, AUTH_TOKEN); setTitle("User Current Location"); }
// Your Twilio phone number (or sender ID) setSize(400, 200); } catch (Exception e) { // Your Twilio phone number (or sender ID) setSize(400, 200); } catch (Exception e) { // Your Twilio phone number (or sender ID) setSize(400, 200); } catch (Exception e) {
String fromPhone = "+12345678901"; // Replace with your Twilio number setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); result = "Error retrieving location"; String fromPhone = "+12345678901"; // Replace with your Twilio number setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); result = "Error retrieving location"; String fromPhone = "+12345678901"; // Replace with your Twilio number setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); result = "Error retrieving location";
// Recipient phone number setLocationRelativeTo(null); } // Recipient phone number setLocationRelativeTo(null); } // Recipient phone number setLocationRelativeTo(null); }
String toPhone = "+10987654321"; // Replace with recipient's phone number return result; String toPhone = "+10987654321"; // Replace with recipient's phone number return result; String toPhone = "+10987654321"; // Replace with recipient's phone number return result;
// Message to send JLabel label = new JLabel("<html>Your Approximate Location:<br>" + location + "</html>"); public static void main(String[] args) { // Message to send JLabel label = new JLabel("<html>Your Approximate Location:<br>" + location + "</html>"); public static void main(String[] args) { // Message to send JLabel label = new JLabel("<html>Your Approximate Location:<br>" + location + "</html>"); public static void main(String[] args) {
String messageBody = "Hello from Java via Twilio!"; add(label); javax.swing.SwingUtilities.invokeLater(() -> { String messageBody = "Hello from Java via Twilio!"; add(label); javax.swing.SwingUtilities.invokeLater(() -> { String messageBody = "Hello from Java via Twilio!"; add(label); javax.swing.SwingUtilities.invokeLater(() -> {
// Send the SMS message } UserLocation app = new UserLocation(); // Send the SMS message } UserLocation app = new UserLocation(); // Send the SMS message } UserLocation app = new UserLocation();
Message message = Message.creator( public String getUserLocation() { app.setVisible(true); Message message = Message.creator( public String getUserLocation() { app.setVisible(true); Message message = Message.creator( public String getUserLocation() { app.setVisible(true);
new PhoneNumber(toPhone), String result = "Location not available"; }); new PhoneNumber(toPhone), String result = "Location not available"; }); new PhoneNumber(toPhone), String result = "Location not available"; });
messageBody) // Use ip-api.com to fetch user location based on IP } messageBody) // Use ip-api.com to fetch user location based on IP } messageBody) // Use ip-api.com to fetch user location based on IP }
.create(); String urlStr = "http://ip-api.com/json"; </content> .create(); String urlStr = "http://ip-api.com/json"; </content> .create(); String urlStr = "http://ip-api.com/json"; </content>
// Print the message SID (for reference) URL url = new URL(urlStr); </create_file> // Print the message SID (for reference) URL url = new URL(urlStr); </create_file> // Print the message SID (for reference) URL url = new URL(urlStr); </create_file>
System.out.println("SMS sent successfully. Message SID: " + message.getSid()); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); System.out.println("SMS sent successfully. Message SID: " + message.getSid()); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); System.out.println("SMS sent successfully. Message SID: " + message.getSid()); HttpURLConnection conn = (HttpURLConnection) url.openConnection();
} BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); } BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); } BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
4 5 6 4 5 6 4 5 6
public static void main(String[] args) { public static void main(String[] args) { public static void main(String[] args) {
VideoCapture camera = new VideoCapture(0); // 0 is the default camera VideoCapture camera = new VideoCapture(0); // 0 is the default camera VideoCapture camera = new VideoCapture(0); // 0 is the default camera
Mat frame = new Mat(); Mat frame = new Mat(); Mat frame = new Mat();
System.out.println("Error: Camera is not available."); System.out.println("Error: Camera is not available."); System.out.println("Error: Camera is not available.");
} } }
HighGui.imshow("Captured Image", frame); // Display the captured image HighGui.imshow("Captured Image", frame); // Display the captured image HighGui.imshow("Captured Image", frame); // Display the captured image
HighGui.waitKey(0); // Wait for a key press HighGui.waitKey(0); // Wait for a key press HighGui.waitKey(0); // Wait for a key press
} } }
camera.release(); // Release the camera camera.release(); // Release the camera camera.release(); // Release the camera
} } }
} } }
7 8 7 8 7 8
Bluetooth code :- send email code :- System.err.println("Error sending email: " + e.getMessage());
public class BluetoothExample { public class SendEmail { // Replace with recipient email, subject and message body
public static void main(String[] args) { private static final String SMTP_HOST = "smtp.gmail.com"; String toEmail = "[email protected]";
try { private static final String SMTP_PORT = "587"; String subject = "Test Email from Java";
final Object inquiryCompletedEvent = new Object(); private static final String USERNAME = "[email protected]"; String body = "Hello!\nThis is a simple email sent from Java.";
DiscoveryListener listener = new DiscoveryListener() { private static final String PASSWORD = "your_email_password_or_app_password"; sendEmail(toEmail, subject, body);
public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { public static void sendEmail(String toEmail, String subject, String body) { }
} props.put("mail.smtp.port", SMTP_PORT);
inquiryCompletedEvent.notifyAll(); }
} });
} try {
public void serviceSearchCompleted(int transID, int respCode) {} Message message = new MimeMessage(session);
}; message.setRecipients(
inquiryCompletedEvent.wait(); Transport.send(message);
1 2 3
Sms code :-
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);