Sorry, this can only be done by a manifest declaration. You can, however, enable or disable the component declared in your manifest at runtime using the PackageManager class.
On Mon, Aug 3, 2009 at 8:40 PM, Anthony Xu <[email protected]> wrote: > > Cannot implement it? > > > On Aug 1, 12:18 pm, Anthony Xu <[email protected]> wrote: > > Hi All, > > > > I must to new a thread. > > > > I know how to implement this issue by Menuifest.xml, see also: > http://groups.google.com/group/android-developers/browse_thread/threa... > > > > But my question is how to add share menu ofGalleryby java code not > > Menuifest.xml. > > My code is as below: > > > > public class MyActivity extends Activity { > > > > private static final String TAG = "MyActivity"; > > > > @Override > > public void onCreate(Bundle savedInstanceState) { > > super.onCreate(savedInstanceState); > > > > IntentFilter intentFilter = new IntentFilter(); > > intentFilter.addAction(Intent.ACTION_SEND); > > intentFilter.addCategory(Intent.CATEGORY_DEFAULT); > > try { > > intentFilter.addDataType("image/*"); > > } catch (MalformedMimeTypeException e) { > > Log.e(TAG, e.toString()); > > } > > > > Intent x = registerReceiver(new BroadcastReceiver() { > > public void onReceive(Context context, Intent intent) { > > Log.d(TAG, "Received intent "+intent); > > intent.setComponent(new ComponentName(context, > > Uploader.class)); > > startActivity(intent); > > } > > }, intentFilter); > > > > if (x==null) > > Log.i(TAG, "failed to regist a receiver"); > > else > > Log.i(TAG, "registed a receiver successfully"); > > // ... > > > > But registerReceiver always return null, and there is no menu added > toGallery'sShare. > > > > Thank you. > > Anthony > > > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

