java - shortcut not opening app on android homescreen -
java - shortcut not opening app on android homescreen -
i have installed few apps on android device, , developed code create shortcut them, work apart 1 app, if manually drag app on homescreen works, i'm confused... next code used create shortcuts
try         {         //log.i("shortcut method in androidhelper start","in shortcutapp on create method ");         boolean flag =false ;         int app_id=-1;         packagemanager p = getpackagemanager();         intent = new intent(intent.action_main);         i.addcategory(intent.category_launcher);          list<resolveinfo> res =p.queryintentactivities( i,0);         //system.out.println("the res size is: "+res.size());          for(int k=0;k<res.size();k++)         {         //log.i("","the application name is: "+res.get(k).activityinfo.loadlabel(p));         if(res.get(k).activityinfo.loadlabel(p).tostring().equals("kortext")){         flag = true;         app_id = k;         break;         }         }          if(flag)         {         activityinfo ai = res.get(app_id).activityinfo;         intent shortcutintent = new intent();         shortcutintent.setclassname(ai.packagename, ai.name);         shortcutintent.addflags(intent.flag_activity_new_task);         shortcutintent.addflags(intent.flag_activity_clear_top);         shortcutintent.addcategory(intent.action_pick_activity);         intent intent = new intent();         intent.putextra(intent.extra_shortcut_intent, shortcutintent);         // sets custom shortcut's title         intent.putextra(intent.extra_shortcut_name, "kortext");          bitmapdrawable bd=(bitmapdrawable)(res.get(app_id).activityinfo.loadicon(p).getcurrent());         bitmap newbit;         newbit=bd.getbitmap();         intent.putextra(intent.extra_shortcut_icon, newbit);          intent.setaction("com.android.launcher.action.install_shortcut");         sendbroadcast(intent);          }         else         {     //  throw new userexception(userexception.kerrgeneral,"application not found");         }          }          catch(activitynotfoundexception e)         {         e.printstacktrace();         //throw new userexception(userexception.kerrgsmrrnoactivityonradiopath,e.getmessage());          }           catch(exception e)         {         e.printstacktrace();         //throw new userexception(userexception.kerrgeneral,e.getmessage());          }    any ideas?
i figured out, had alter intents new intent(intent.action_main);
 java android 
 
Comments
Post a Comment