--
Carlos Eduardo Simões Pelegrin
Ótimo!!! :)Abraços,
Pedro Subutzki
__________________________________________HADI - Makes SQLite in Android easy and simple
https://github.com/PepeuCps/HadiEm 24 de setembro de 2013 14:48, Gerson Felipe <gersongfpn@gmail.com> escreveu::)Atenciosamente,
Gerson NovaisEm 24 de setembro de 2013 14:45, Carlos Eduardo <carloseduardopelegrin@gmail.com> escreveu:
Funcionou assim:Setei o context = getApplicationContext(); no onCreate;
public void createShortcut(){Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");// Shortcut nameshortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "nome do atalho");shortcut.putExtra("duplicate", false); // Just create once// Setup activity shoud be shortcut objectComponentName component = new ComponentName(getPackageName(), getClass().getName());shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).setComponent(component));// Set shortcut iconShortcutIconResource iconResource = Intent.ShortcutIconResource .fromContext(context,R.drawable.ic_launcher);shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);context.sendBroadcast(shortcut);}Igual o Pedro falou, até hoje para mim não havia feito diferença!Obrigado aos dois pela ajuda!Att.
--
Carlos Eduardo Simões PelegrinEm 24 de setembro de 2013 14:36, Gerson Felipe <gersongfpn@gmail.com> escreveu:@PedroÉ isso ae...Procurando nos meus favoritos aqui de muito tempo atras, encontrei isso aqui para fortalecer mais esse e-mail com conteúdo de qualidade (mesmo que não ajude o amigo ai..)
View.getContext(): Returns the context the view is currently running in. Usually the currently active Activity.
Activity.getApplicationContext(): Returns the context for the entire application (the process all the Activities are running inside of). Use this instead of the current Activity context if you need a context tied to the lifecycle of the entire application, not just the current Activity.
ContextWrapper.getBaseContext(): If you need access to a Context from within another context, you use a ContextWrapper. The Context referred to from inside that ContextWrapper is accessed via getBaseContext().
Atenciosamente,
Gerson NovaisEm 24 de setembro de 2013 14:34, Pedro Subutzki <Pepeu> <falecompepeu@gmail.com> escreveu:
@GersonExato. O contexto da aplicação é bem diferente do contexto da aplicação apesar de em muitos lugares isso não fazer tanta diferença.Porém usar de qualquer jeito sem saber "como" e "pra quê serve" sempre podem trazer problemas. ;)Abraços,
Pedro Subutzki
__________________________________________HADI - Makes SQLite in Android easy and simple
https://github.com/PepeuCps/HadiEm 24 de setembro de 2013 14:31, Gerson Felipe <gersongfpn@gmail.com> escreveu:Tente usar o getApplicationContext neste final de código, quando vc faz o BroadCast.O this retorna o contexto da View, geralmente usado para a Activity atual.Atenciosamente,
Gerson NovaisEm 24 de setembro de 2013 14:27, Carlos Eduardo <carloseduardopelegrin@gmail.com> escreveu:
estou setando o contexto em onCreate.private Context context;protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);context = this;...Obrigado
--
Carlos Eduardo Simões PelegrinEm 24 de setembro de 2013 14:26, Gerson Felipe <gersongfpn@gmail.com> escreveu:no seu código eu não vi qual é o seu context, como vc está obtendo este context, que vc usa no final do código no broadcast.Atenciosamente,
Gerson NovaisEm 24 de setembro de 2013 14:19, Carlos Eduardo <carloseduardopelegrin@gmail.com> escreveu:
Bom, Se vc olhar o exemplo no link vai ver que é idêntico ao meu e não funciona.O segundo eu já havia testado e nem criar o ícone ele cria!Att.
--
Carlos Eduardo Simões PelegrinEm 24 de setembro de 2013 14:10, Gerson Felipe <gersongfpn@gmail.com> escreveu:Atenciosamente,
Gerson NovaisEm 24 de setembro de 2013 14:08, Carlos Eduardo <carloseduardopelegrin@gmail.com> escreveu:
Eu gostaria que meu aplicativo criasse um ícone/atalho na HomeScreen na primeira vez q fosse executado.att.
--
Carlos Eduardo Simões PelegrinEm 24 de setembro de 2013 14:05, Pedro Subutzki <Pepeu> <falecompepeu@gmail.com> escreveu:
Carlos,O que você precisa fazer? Que ícone você quer criar?Abraços,
Pedro Subutzki
__________________________________________HADI - Makes SQLite in Android easy and simple
https://github.com/PepeuCps/HadiEm 24 de setembro de 2013 13:59, Carlos Eduardo <carloseduardopelegrin@gmail.com> escreveu:
sim, ao meu ponto de vista isso funcionaria para que o ícone fosse criado apenas uma vez na tela não?Independente do número de vezes que eu chamar o método ele não deveria criar mais ícones. Ou estou enganado?
--
Carlos Eduardo Simões PelegrinEm 24 de setembro de 2013 13:54, Pedro Subutzki <Pepeu> <falecompepeu@gmail.com> escreveu:
O "duplicate = false". Não é isso que você está querendo manter durante a execução?Abraços,
Pedro Subutzki
__________________________________________HADI - Makes SQLite in Android easy and simple
https://github.com/PepeuCps/HadiEm 24 de setembro de 2013 13:50, Carlos Eduardo <carloseduardopelegrin@gmail.com> escreveu:
Desculpe não entendi,Qual valor?
--
Carlos Eduardo Simões Pelegrin2013/9/24 Pedro Subutzki <Pepeu> <falecompepeu@gmail.com>Já tentou criar uma classe estática pra guardar o valor que você precisa?Abraços,
Pedro Subutzki
__________________________________________HADI - Makes SQLite in Android easy and simple
https://github.com/PepeuCps/Hadi2013/9/24 Carlos Pelegrin <carloseduardopelegrin@gmail.com>Boa tarde pessoal,--Estou utilizando esse código:public void createShortcut(){Intent shortcutIntent = new Intent();shortcutIntent.setClassName(getPackageName(), getClass().getName());Intent addIntent = new Intent();addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "nome do atalho");addIntent.putExtra("duplicate", false); //Aqui não funcionaaddIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,Intent.ShortcutIconResource.fromContext(context, R.drawable.ic_launcher));addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");context.sendBroadcast(addIntent);}Bom, tudo legal na primeira execução, mas o putExtra("duplicate", false); não funciona como planejado.Se eu abrir o aplicativo 10 vezes, ele cria 10 ícones.Estou instanciando o método no onCreate.Alguém já passou por esse problema? alguém sabe o motivo disso?Obrigado
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 comentários:
Postar um comentário