Search Results

Search found 13 results on 1 pages for 'brono the vibrator'.

Page 1/1 | 1 

  • Show Alertdialog and use vibrator

    - by user1007522
    I'm having a class that implements RecognitionListener like this: public class listener implements RecognitionListener I wanted to show a alertdialog and use the vibrator but this isn't possible because I need to provide a context what I don't have. My alertdialog code was like this: new AlertDialog.Builder(this) .setTitle("dd") .setMessage("aa") .setNeutralButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }) .show(); But the AlertDialog.Builder(this) wants a context, the same problem with my vibrator code: v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); The getSystemService method isn't available. My code that starts the class: sr = SpeechRecognizer.createSpeechRecognizer(this); sr.setRecognitionListener(new listener()); Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"voice.recognition.test"); intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,5); sr.startListening(intent); Whats the best way to solve this?

    Read the article

  • Service with intents not working. Help needed

    - by tristan202
    I need help in making my click intents work. I used to have them in my appwidgetprovider, but decided to move them into a service, but I am having trouble getting it to work. Below is the entire code from my intentservice: public class IntentService extends Service { static final String ACTION_UPDATE = "android.tristan.widget.digiclock.action.UPDATE_2"; private final static IntentFilter sIntentFilter; public int layoutID = R.layout.clock; int appWidgetIds = 0; static { sIntentFilter = new IntentFilter(); } @Override public IBinder onBind(Intent intent) { return null; } @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); } @Override public void onCreate() { super.onCreate(); registerReceiver(onClickTop, sIntentFilter); registerReceiver(onClickBottom, sIntentFilter); Log.d("DigiClock IntentService", "IntentService Started."); } @Override public void onDestroy() { super.onDestroy(); unregisterReceiver(onClickTop); unregisterReceiver(onClickBottom); } private final BroadcastReceiver onClickTop = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals("android.tristan.widget.digiclock.CLICK")) { PackageManager packageManager = context.getPackageManager(); Intent alarmClockIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER); String clockImpls[][] = { {"HTC Alarm Clock", "com.htc.android.worldclock", "com.htc.android.worldclock.WorldClockTabControl" }, {"Standar Alarm Clock", "com.android.deskclock", "com.android.deskclock.AlarmClock"}, {"Froyo Nexus Alarm Clock", "com.google.android.deskclock", "com.android.deskclock.DeskClock"}, {"Moto Blur Alarm Clock", "com.motorola.blur.alarmclock", "com.motorola.blur.alarmclock.AlarmClock"} }; boolean foundClockImpl = false; for(int i=0; i<clockImpls.length; i++) { String vendor = clockImpls[i][0]; String packageName = clockImpls[i][1]; String className = clockImpls[i][2]; try { ComponentName cn = new ComponentName(packageName, className); ActivityInfo aInfo = packageManager.getActivityInfo(cn, PackageManager.GET_META_DATA); alarmClockIntent.setComponent(cn); foundClockImpl = true; } catch (NameNotFoundException e) { Log.d("Error, ", vendor + " does not exist"); } } if (foundClockImpl) { Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(50); final RemoteViews views = new RemoteViews(context.getPackageName(), layoutID); views.setOnClickPendingIntent(R.id.TopRow, PendingIntent.getActivity(context, 0, new Intent(context, DigiClock.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK), PendingIntent.FLAG_UPDATE_CURRENT)); AppWidgetManager.getInstance(context).updateAppWidget(intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS), views); alarmClockIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(alarmClockIntent); } } } }; private final BroadcastReceiver onClickBottom = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals("android.tristan.widget.digiclock.CLICK_2")) { PackageManager calendarManager = context.getPackageManager(); Intent calendarIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER); String calendarImpls[][] = { {"HTC Calendar", "com.htc.calendar", "com.htc.calendar.LaunchActivity" }, {"Standard Calendar", "com.android.calendar", "com.android.calendar.LaunchActivity"}, {"Moto Blur Calendar", "com.motorola.blur.calendar", "com.motorola.blur.calendar.LaunchActivity"} }; boolean foundCalendarImpl = false; for(int i=0; i<calendarImpls.length; i++) { String vendor = calendarImpls[i][0]; String packageName = calendarImpls[i][1]; String className = calendarImpls[i][2]; try { ComponentName cn = new ComponentName(packageName, className); ActivityInfo aInfo = calendarManager.getActivityInfo(cn, PackageManager.GET_META_DATA); calendarIntent.setComponent(cn); foundCalendarImpl = true; } catch (NameNotFoundException e) { Log.d("Error, ", vendor + " does not exist"); } } if (foundCalendarImpl) { Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(50); final RemoteViews views2 = new RemoteViews(context.getPackageName(), layoutID); views2.setOnClickPendingIntent(R.id.BottomRow, PendingIntent.getActivity(context, 0, new Intent(context, DigiClock.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK), PendingIntent.FLAG_UPDATE_CURRENT)); AppWidgetManager.getInstance(context).updateAppWidget(intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS), views2); calendarIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(calendarIntent); } } }; }; ;}; What am I doing wrong here?

    Read the article

  • how to redirect on youtube in androi

    - by rajshree
    public class MovieDescription extends Activity { Vibrator vibrator; TextView tv_title,tv_year,tv_banner,tv_desc; RatingBar ratingBar; ImageView iv_watch,iv_poster; private static final String TAG_CONTACTS = "Demo"; private static final String TAG_ID = "id"; private static final String TAG_TITLE = "title"; private static final String TAG_YEAR = "year"; private static final String TAG_RATING = "rating"; private static final String TAG_BANNER= "category"; private static final String TAG_DESC = "description"; private static final String TAG_URL = "url"; private static final String TAG_POSTER = "poster"; String id,title,year,rating,banner,description,poster, movieUrl; static JSONArray contacts = null; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.movie_description); initialize(); String movieDescUrl = "http://vaibhavtech.com/work/android/movie_description.php?id="+MainActivity.movie_Id; MovieDescriptionParser jParser = new MovieDescriptionParser(); JSONObject json = jParser.getJSONFromUrl(movieDescUrl); try { contacts = json.getJSONArray(TAG_CONTACTS); for (int i = 0; i < contacts.length(); i++) { /**********************************Value Parse FromUrl**********************************/ JSONObject c = contacts.getJSONObject(i); id = c.getString(TAG_ID); title = c.getString(TAG_TITLE); year = c.getString(TAG_YEAR); rating = c.getString(TAG_RATING); banner=c.getString(TAG_BANNER); description = c.getString(TAG_DESC); movieUrl = c.getString(TAG_URL); poster = c.getString(TAG_POSTER); /**********************************Valeu Assing to UI Component**********************************/ Log.i(id, title); } } catch (JSONException e) { e.printStackTrace(); } tv_title.setText(title); tv_year.setText(year); tv_banner.setText(banner); tv_desc.setText(description); Float rat=Float.parseFloat(rating); ratingBar.setRating(rat); Bitmap bimage= getBitmapFromURL("http://vaibhavtech.com/work/android/admin/upload/"+poster); iv_poster.setImageBitmap(bimage); iv_watch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub vibrator.vibrate(40); LayoutInflater inflater=getLayoutInflater(); View view=inflater.inflate(R.layout.customtoast,(ViewGroup)findViewById(R.id.custom_toast_layout)); Toast toast=new Toast(getApplicationContext()); toast.setDuration(Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER_HORIZONTAL, 0, 0); toast.setView(view); toast.show(); Intent intent=new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(movieUrl)); startActivity(intent); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // TODO Auto-generated method stub int currentapiVersion = android.os.Build.VERSION.SDK_INT; Log.i("Device Versoin is", ""+currentapiVersion); if (currentapiVersion >= android.os.Build.VERSION_CODES.JELLY_BEAN){ ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); getMenuInflater().inflate(R.menu.main, menu); } return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { // TODO Auto-generated method stub switch (item.getItemId()) { case android.R.id.home: onBackPressed(); return true; case R.id.home: Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); Log.i("Home", "Press"); return true; } return super.onOptionsItemSelected(item); } public void initialize() { tv_banner=(TextView) findViewById(R.id.tv_movie_description_banner); tv_desc=(TextView) findViewById(R.id.tv_movie_description_decription); tv_title=(TextView) findViewById(R.id.tv_movie_description_name); tv_year=(TextView) findViewById(R.id.tv_movie_description_year); ratingBar=(RatingBar) findViewById(R.id.ratingBar1); iv_watch=(ImageView) findViewById(R.id.iv_movie_description_watch); iv_poster=(ImageView) findViewById(R.id.iv_movie_description_poster); vibrator=(Vibrator)getSystemService(Context.VIBRATOR_SERVICE);; } public static Bitmap getBitmapFromURL(String src) { try { Log.i("src",src); URL url = new URL(src); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoInput(true); connection.connect(); InputStream input = connection.getInputStream(); Bitmap myBitmap = BitmapFactory.decodeStream(input); Log.i("Bitmap","returned"); return myBitmap; } catch (IOException e) { e.printStackTrace(); Log.e("Exception",e.getMessage()); return null; } } } when i am clciking on watch now button its giving me 4 options -by mozilz,by chrome,by youtube, i want that when i click on watch now button it get redirect on youtube url link,..how can i do this please give me any suggetion.:(

    Read the article

  • Entity Framework Adding new record with foreign key constraint

    - by Brono The Vibrator
    In an effort to learn the entity framework I have created two tables in a one to many relationship. The one table (Author) has the following fields - AuthorID, FirstName, LastName. The many table (Payroll) has the following fields - PayrollID, AuthorID, Salary. I have CRUD stored procdures for insert, update and delete. What I am tying to figure-out is how to add new payroll records to the payroll table.

    Read the article

  • Converting VB .NET code to C#

    - by Brono The Vibrator
    I have the follwing VB .NET code I am trying to convert to C# Dim decryptedBytes(CInt(encryptedStream.Length - 1)) As Byte I tried this: int tempData = Convert.ToInt32(encryptedStream.Length - 1); Byte decryptedBytes; decryptedBytes = decryptedBytes[tempData]; but got this error message: Cannot apply indexing with [] to an expression of type byte. Please note that the VB .NET code works.

    Read the article

  • How to remove the port number from a url string

    - by Brono The Vibrator
    I have the following code snippet: string tmp = String.Format("javascript:window.open('{0}');", url); ClientScript.RegisterClientScriptBlock(this.GetType(), "NewWindow", tmp); the url generated by this code include the port number and I think that is happening becasue port 80 is used by the website and in this code I am trying to load a page from a virtual directory of the website. Any ideas on how to supress the port number in the url string generated by this code?

    Read the article

  • destroy an android service

    - by Jack Trowbridge
    I am using a service in my android app, which is called when an alarm is activated by a calander. When the service has been activated i want it to be destroyed by the OnStart() method once it has completed its code. My OnStart() method: @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); Vibrator vi = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); vi.vibrate(5000); Toast.makeText(this, "MyAlarmService.onStart()", Toast.LENGTH_LONG).show(); //CODE HERE TO DESTROY SERVICE?? } This bassically means when the service is called it runs the code in the OnStart() method and i want it to destroy itself. Any Ideas, methods that would do this?. Thanks, jack.

    Read the article

  • my computer makes vibrating sounds

    - by Nrew
    I don't know why but every morning when I turn on the computer, it makes a vibrating sound. Like its case is attached to a vibrator. But when I turn it off and turn on again using the power button(still at os choices) the sound is gone. Why is my computer creating the sound?

    Read the article

  • Virtual Brown Bag Recap: NuGet, PoshCode, Code Templates

    - by Brian Schroer
    "Virtual Brown Bag" anagrams: Roving Tuba Brawl Lawn Bug Vibrator Rubbing Two Larva Vulgar Rabbi Town A Vibrant Grub Owl Blurting a Bar Vow At this week's Roving Tuba Brawl Virtual Brown Bag meeting: Claudio Lassala asked "What does your work environment look like?" He and several others shared pictures. George Mauer talked about NuGet, .NET's answer to Ruby Gems, and PoshCode, a PowerShell code repository Claudio showed how he uses CodeRush templates to quickly generate unit test code Alan Stevens showed how to do the same thing with Resharper templates For detailed notes, links, and the video recording, go to the VBB wiki page: https://sites.google.com/site/vbbwiki/main_page/2010-12-02

    Read the article

  • How to check if vibration happened, in logcat?

    - by Mithraa
    I searched in the web but i couldn find a single article dealing in a straight forward way on how to find the vibrate on/off logs in logcat. If anybody who is aware of the procedure, please enlighten me. Once again i need it specifically to check if my app triggers vibrator or not...

    Read the article

  • Vibration after regular intervals

    - by umar
    I have a beep system which gives you four beeps. One beep after a second for one second. However If its silent mode i want the vibrator to do the same, vibrate for 1 second 4 times after 1 second. This is the code I am using long[] pattern = new long[2]; pattern[0] = 10; pattern [1] = 30; switch (am.getRingerMode()) { case AudioManager.RINGER_MODE_VIBRATE: vibe.vibrate(pattern, 0); break; case AudioManager.RINGER_MODE_NORMAL: soundsOn(mp); break; Kindly how can i do what i want to do Best Regards

    Read the article

  • Thread Blocks During Call

    - by user578875
    I have a serious problem, I'm developing an application that mesures on call time during a call; the problem presents when, with the phone on the ear, the thread that the timer has, blocks and no longer responds before taking off my ear. The next log shows the problem. 01-11 16:14:19.607 14558 14566 I Estado : postDelayed Async Service 01-11 16:14:20.607 14558 14566 I Estado : postDelayed Async Service 01-11 16:14:21.607 14558 14566 I Estado : postDelayed Async Service 01-11 16:14:22.597 14558 14566 I Estado : postDelayed Async Service 01-11 16:14:23.608 14558 14566 I Estado : postDelayed Async Service 01-11 16:14:24.017 1106 1106 D iddd : select() < 0, Probably a handled signal: Interrupted system call 01-11 16:14:24.607 14558 14566 I Estado : postDelayed Async Service 01-11 16:18:05.500 1106 1106 D iddd : select() < 0, Probably a handled signal: Interrupted system call 01-11 16:18:06.026 14558 14566 I Estado : postDelayed Async Service 01-11 16:18:06.026 14558 14566 I Estado : postDelayed Async Service 01-11 16:18:06.026 14558 14566 I Estado : postDelayed Async Service 01-11 16:18:06.026 14558 14566 I Estado : postDelayed Async Service 01-11 16:18:06.026 14558 14566 I Estado : postDelayed Async Service 01-11 16:18:06.026 14558 14566 I Estado : postDelayed Async Service I've been trying with Services, Timers, Threads, AyncTasks and they all present the same problem. My Code: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); HangUpService.setMainActivity(this); objHangUpService = new Intent(this, HangUpService.class); Runnable rAccion = new Runnable() { public void run() { TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); tm.listen(mPhoneListener, PhoneStateListener.LISTEN_CALL_STATE); objVibrator = (Vibrator) getSystemService(getApplicationContext().VIBRATOR_SERVICE); final ListView lstLlamadas = (ListView) findViewById(R.id.lstFavoritos); final EditText txtMinutos = (EditText) findViewById(R.id.txtMinutos); final EditText txtSegundos = (EditText) findViewById(R.id.txtSegundos); ArrayList<Contacto> cContactos = new ArrayList<Contacto>(); ContactoAdapter caContactos = new ContactoAdapter(HangUp.this, R.layout.row,cContactos); Cursor curContactos = getContentResolver().query( ContactsContract.Contacts.CONTENT_URI, null, null, null, ContactsContract.Contacts.TIMES_CONTACTED + " DESC"); while (curContactos.moveToNext()){ String strNombre = curContactos.getString(curContactos.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); String strID = curContactos.getString(curContactos.getColumnIndex(ContactsContract.Contacts._ID)); String strHasPhone=curContactos.getString(curContactos.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)); String strStarred=curContactos.getString(curContactos.getColumnIndex(ContactsContract.Contacts.STARRED)); if (Integer.parseInt(strHasPhone) > 0 && Integer.parseInt(strStarred) ==1 ) { Cursor CursorTelefono = getContentResolver().query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = " + strID, null, null); while (CursorTelefono.moveToNext()) { String strTipo=CursorTelefono.getString(CursorTelefono.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE)); String strTelefono=CursorTelefono.getString(CursorTelefono.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); strNumero=strTelefono; String args[]=new String[1]; args[0]=strNumero; Cursor CursorCallLog = getContentResolver().query( android.provider.CallLog.Calls.CONTENT_URI, null, android.provider.CallLog.Calls.NUMBER + "=?", args, android.provider.CallLog.Calls.DATE+ " DESC"); if (Integer.parseInt(strTipo)==2) { caContactos.add( new Contacto( strNombre, strTelefono ) ); } } CursorTelefono.close(); } } curContactos.close(); lstLlamadas.setAdapter(caContactos); lstLlamadas.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView a, View v, int position, long id) { Contacto mContacto=(Contacto)lstLlamadas.getItemAtPosition(position); i = new Intent(HangUp.this, Llamada.class); Log.i("Estado","Declaro Intent"); Bundle bundle = new Bundle(); bundle.putString("telefono", mContacto.getTelefono()); i.putExtras(bundle); startActivityForResult(i,SUB_ACTIVITY_ID); Log.i("Estado","Inicio Intent"); blActivo=true; try { String strMinutos=txtMinutos.getText().toString(); String strSegundos=txtSegundos.getText().toString(); if(!strMinutos.equals("") && !strSegundos.equals("")){ int Tiempo = ( (Integer.parseInt(txtMinutos.getText().toString())*60) + Integer.parseInt(txtSegundos.getText().toString()) )* 1000; handler.removeCallbacks(rVibrate); cTime = System.currentTimeMillis(); cTime=cTime+Tiempo; objHangUpAsync = new HangUpAsync(cTime,objVibrator,objPowerManager,objKeyguardLock); objHangUpAsync.execute(); objPowerManager.userActivity(Tiempo+3000, true); objHangUpService.putExtra("cTime", cTime); //startService(objHangUpService); } catch (Exception e) { e.printStackTrace(); } finally { } } }); } }; } AsyncTask: @Override protected String doInBackground(String... arg0) { blActivo = true; mWakeLock = objPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Tag"); objKeyguardLock.disableKeyguard(); Log.i("Estado", "Entro a doInBackground"); timer.scheduleAtFixedRate( new TimerTask() { public void run() { if (blActivo){ if (cTime blActivo=false; objVibrator.vibrate(1000); Log.i("Estado","Vibrar desde Async"); this.cancel(); }else{ try{ mWakeLock.acquire(); mWakeLock.release(); Log.i("Estado","postDelayed Async Service"); }catch(Exception e){ Log.i("Estado","Error: " + e.getMessage()); } } } } }, 0, INTERVAL); return null; }

    Read the article

1