In the onReceive that you've just
implemented, you got a context and
an intent.
Now remember earlier when you
broadcasted the detected activities,
you created an array list
of detected activities and
you put them into the intent.
See now if you can create a new array
list of detected activities and
get them out of the intent.
And here's a hint, you can use the get
parcelable array list extra method.
On the intent to do it.
Check out the documentation for that.
But that's the key.
Now, once you've done this, you're going
to easily iterate through this array
list of detected activities, and you
can get their type using the getType.
Once you've done this you can iterate
through the DetectedActivity objects in
the ArrayList.
Getting their type and the confidence
for this type using the getType and
getConfidence methods.
Note that getType will actually
return a code and not the string for
the activity.
You can find these codes on
the DetectedActivity class.
Go ahead now and write a helper function
that turns this code into a string,
and then implement
this on your onReceive.
When you're done, check this box.
في دالة المستقبل التي قمت بتنفيذها، حصلت
على سياق
وغرض.
عد بالذاكرة إلى الوراء عندما قمت
بإرسال الأنشطة المكتشفة،
كونت قائمة صفيفة من الأنشطة المكتشفة
ووضعتهم في الغرض
جرب الآن ما إذا كنت تستطيع تكوين قائمة
صفيفة جديدة من الأنشطة المكتشفة
وقم بوضعهم في الغرض.
وهنا تلميح، يمكن أن تستخدم دالة الحصول
على قائمة صفيفة إضافية.
من خلال الغرض.
قم بالاطلاع على المراجع الخاصة بذلك.
هذا هو المفتاح
الآن، بعد قيامك بذلك، يمنك استخدام
هذه
القائمة الصفيفة من الأنشطة المكتشفة، ويمكن
أن تحصل على الأنواع باستخدام دالة الانواع.
بعد قيامك بذلك يمكنك أن تستخدم عناصر
النشاط المكتشف
القائمة الصفيفة.
الحصول على نوع و دقة هذا النوع باستخدام
دالة الحصول على النوع
ودالة الحصول على دقة النوع.
لاحظ أن دالة الحصول على النوع ستتحول إلى
تعليمة برمجية وليس عبارة
النشاط.
يمكن أن تجد هذه التعاليم البرمجية في
فئة النشاط المكتشف.
لنبدأ الآن وتنفيذ دالة مساعدة لتحويل
تلك التعليمة إلى عبارة،
وتنفيذ ذلك من خلال دالة المستقبل.
قم باختيار الخانة بعد ذلك.
No onReceive
que você implementou,
há um contexto e um intent.
Lembre-se de antes, quando você
transmitiu as atividades detectadas,
criou uma ArrayList
das atividades detectadas
e as colocou no intent.
Veja agora se consegue criar uma nova
ArrayList de atividades detectadas e
retirá-las do intent.
Dica: você pode usar o método
getParcelableArrayListExtra
no intent para isso.
Confira a documentação
para mais informações.
Mas essa é a chave.
Depois disso,
você realizará a iteração
dessa ArrayList de atividades
detectadas com facilidade
e poderá obter o tipo delas
usando getType.
Depois, você poderá realizar a iteração
dos objetos DetectedActivity
na ArrayList.
O tipo e confiança desse tipo
serão obtidos usando os métodos
getType e getConfidence.
Veja que getType
retornará um código,
não a string
da atividade.
Esses códigos são encontrados
na classe DetectedActivity.
Vá em frente.
Escreva uma função auxiliar
que transforme o código em string
e implemente
em onReceive.
Quando terminar,
marque esta caixa.
在你刚刚实施的 onReceive 中 你得到一个 context
和一个 intent
请记住 早些时候广播检测的 activity 时
你创建了一个检测 activity 数组列表
并将这些 activity 放在 intent 中
现在看一下 你是否能创建一个新的检测 activity 数组列表
并从 intent 中得到这些 activity
提示一下 你可以使用 intent 上 getParcelableArrayListExtra 方法
进行操作
检查此 activity 的文件
但这是关键
如果已经完成这一步 你将轻松地逐个检查检测 activity 数组列表
并且可以使用 getType 获得它们的类别
如果已经完成这一步 就可以逐个检查 ArryList 中的
DetectedActivity 对象
使用 getType 和 getConfidence 方法
获得它们的类别和对此类别的信任
注意 getType 将实际上返回 activity 的
一个代码而不是字符串
你可以在 DetectedActivity 类上找到这些代码
现在继续 编写一个可将此代码转变为字符串的帮助函数
然后在 onReceive 上实施
完成后请选中此方框