Ana iya yin rawar jiki ta na'urar Android da tsari ta hanyar Android SDK. Ana iya amfani da wannan fasalin ta hanyoyi da yawa kamar samar da ra'ayi mai ma'ana don ayyukan mai amfani, faษakar da mai amfani da hankali game da sabuntawa, ko ma baiwa 'yan wasan ฦwarewa ฦwarewa mai zurfi. Yana da kayan aiki mai mahimmanci kuma mai amfani don ฦirฦirar ฦarin ฦwarewar mai amfani.
Babban aikin da ke cikin wannan aiki shine sabis na tsarin Android da ake kira Vibrator, wanda ke sarrafa injin girgiza na'urar. Dole ne a ba da wasu izini a cikin bayanan aikace-aikacen don amfani da wannan aikin, kuma kayan aikin na'urar dole ne su goyi bayansa.
Kafin mu ci gaba, bari mu nutse cikin mahimman batutuwa.
Sabis na Vibrator
Sabis ษin tsarin Android, Vibrator, yana taimaka mana mu yi amfani da aikin jijjiga a cikin na'urorin Android ta hanyar shirye-shirye a cikin aikace-aikacen mu. Don kiran wannan hanyar, muna buฦatar jefa sabis ษin tsarin zuwa abu mai Vibrator ta amfani da getSystemService().
// Get instance of Vibrator from current Context Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
Abun Vibrator yana ba da ฦดan hanyoyi don sarrafa ayyukan girgiza, gami da girgiza() da soke().
Izinin Android
Kafin mu iya amfani da sabis na vibrator, muna buฦatar ayyana izinin VIBRATE a cikin bayanan aikace-aikacen mu. Wannan yana sanar da masu amfani cewa aikace-aikacen na iya sarrafa injin girgiza yayin aiki.
<manifest ...> <uses-permission android_name="android.permission.VIBRATE"/> ... </manifest>
Ana aiwatar da Vibration
Bayan saita izini masu dacewa, zamu iya amfani da hanyar vibrate() da muka ambata a baya don sanya na'urar ta girgiza.
// Start without a delay // Vibrate for 100 milliseconds // Sleep for 1000 milliseconds long[] pattern = {0, 100, 1000}; // The '0' here means to repeat indefinitely // '-1' would play the vibration once v.vibrate(pattern, 0);
Wannan lambar tana sa na'urar ta yi rawar jiki har na miliyon 100 sannan ta tsaya tsayin miliyon 1000, tana maimaita wannan tsari har abada.
Idan kuna son dakatar da jijjiga, zaku iya yin hakan ta hanyar kiran hanyar soke ().
v.cancel();
Waษannan su ne mahimman matakai don aiwatar da rawar jiki a cikin tsarin Android. Haษa waษannan abubuwan haษin gwiwa na iya taimakawa haษaka ฦwarewar mai amfani da ku, ฦirฦirar ฦarin aikace-aikacen hulษa.
Ka tuna cewa ba duk na'urori ne ke goyan bayan wannan aikin ba, kuma ya kamata mu yi la'akari da yanayi inda girgiza ya kamata ya zama na zaษi, samar da saiti ga masu amfani waษanda suka fi son kashe ra'ayin haptic.
A ฦarshe, Android tana ba da aiki don samun dama da sarrafa kayan aikin na'urar kamar injin girgiza. A matsayin masu haษakawa, za mu iya amfani da waษannan ayyukan don haษaka hulษar mai amfani na aikace-aikacen mu. Koyaya, yana da mahimmanci a yi amfani da waษannan albarkatu cikin hikima, kiyaye abubuwan da mai amfani ke so a tsakiya.