חיבור מכשירים באופן אלחוטי
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
בנוסף לאפשרות לתקשר עם הענן, ממשקי ה-API האלחוטיים של Android מאפשרים גם לתקשר עם מכשירים אחרים באותה רשת מקומית, ואפילו עם מכשירים שלא מחוברים לרשת אבל נמצאים פיזית בקרבת מקום. הוספת Network Service Discovery (NSD) מאפשרת לאפליקציה לחפש מכשיר בקרבת מקום שבו פועלים שירותים שהיא יכולה לתקשר איתם.
שילוב התכונה הזו באפליקציה שלכם יעזור לכם לספק מגוון רחב של תכונות, כמו לשחק במשחקים עם משתמשים באותו חדר, לשלוף תמונות ממצלמת אינטרנט עם תמיכה ב-NSD ברשת או להתחבר מרחוק למכונות אחרות באותה רשת.
בכיתה הזו מתוארים ממשקי ה-API העיקריים לאיתור ולחיבור למכשירים אחרים מהאפליקציה. באופן ספציפי, מתואר בו ה-NSD API לגילוי שירותים זמינים, ו-Wi-Fi Peer-to-Peer (P2P) API ליצירת חיבורים אלחוטיים בין משתמשים. בשיעור הזה נסביר גם איך להשתמש ב-NSD וב-Wi-Fi P2P
כדי לזהות את השירותים שהמכשיר מציע ולהתחבר למכשיר
כשאף מכשיר לא מחובר לרשת.
אם אתם מחפשים ממשק API ברמה גבוהה יותר עבור האפליקציה ל-Android,
להעביר נתונים בצורה אמינה ומאובטחת בין מכשירים באמצעות שילוב של Wi-Fi
ו-Bluetooth, מומלץ להשתמש ב-Nearby Connections API.
שיעורי מוזיקה
- שימוש בשירותי זיהוי רשת
- ללמוד איך לשדר שירותים שמוצעים
באמצעות האפליקציה שלכם, לגלות שירותים שמוצעים ברשת המקומית
להשתמש ב-NSD כדי לקבוע את פרטי החיבור לשירות שרוצים
להתחבר אליהם.
- יצירת חיבורי P2P באמצעות Wi-Fi
- כך אפשר לאחזר רשימה של מכשירי עמיתים בקרבת מקום, ליצור נקודת גישה למכשירים מדור קודם ולהתחבר למכשירים אחרים עם תמיכה בחיבורי Wi-Fi P2P.
- שימוש ב-Wi-Fi P2P לצורך גילוי שירותים
- איך למצוא שירותים
פורסמו על ידי מכשירים בקרבת מקום בלי להתחבר לאותה רשת, באמצעות Wi-Fi
P2P.
כדאי גם לקרוא את המאמרים הבאים:
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-26 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-07-26 (שעון UTC)."],[],[],null,["# Connect devices wirelessly\n\nBesides enabling communication with the cloud, Android's wireless APIs also\nenable communication with other devices on the same local network, and even\ndevices which are not on a network, but are physically nearby. The addition of\nNetwork Service Discovery (NSD) takes this further by allowing an application to\nseek out a nearby device running services with which it can communicate.\nIntegrating this feature into your application helps you provide a wide range of\nfeatures, such as playing games with users in the same room, pulling images from\na networked NSD-enabled webcam, or remotely logging into other machines on the\nsame network.\n\nThis class describes the key APIs for finding and connecting to other devices\nfrom your application. Specifically, it describes the NSD API for discovering\navailable services and the Wi-Fi Peer-to-Peer (P2P) API for doing peer-to-peer\nwireless connections. This class also shows you how to use NSD and Wi-Fi P2P in\ncombination to detect the services offered by a device and connect to the device\nwhen neither device is connected to a network.\n\nIf you're looking for a higher-level API for your Android application to\ntransfer data reliably and securely between devices using a combination of Wi-Fi\nand Bluetooth, consider using the [Nearby Connections API](https://developers.google.com/nearby/connections/overview). \n\nLessons\n-------\n\n**[Use network service discovery](/develop/connectivity/wifi/use-nsd)**\n: Learn how to broadcast services offered\n by your own application, discover services offered on the local network, and\n use NSD to determine the connection details for the service you want to\n connect to.\n\n**[Creating P2P connections with Wi-Fi](/develop/connectivity/wifi/wifi-direct)**\n: Learn how to fetch a list of\n nearby peer devices, create an access point for legacy devices, and connect\n to other devices capable of Wi-Fi P2P connections.\n\n**[Using Wi-Fi P2P for service discovery](/develop/connectivity/wifi/nsd-wifi-direct)**\n: Learn how to discover services\n published by nearby devices without being on the same network, using Wi-Fi\n P2P.\n\nYou should also read\n--------------------\n\n- [Wi-Fi P2P](/develop/connectivity/wifi/wifip2p)\n- [Nearby Connections API](https://developers.google.com/nearby/connections/overview)"]]