从其他apk访问类

时间:2011-01-12 12:15:43

标签: android

我想知道是否可以从另一个apk直接访问apk中的类。

例如,在记事本教程中,这些代码行启动了一项活动:

 
    Intent i = new Intent(this, NoteEdit.class);
    startActivityForResult(i, ACTIVITY_CREATE);
此代码直接访问NoteEdit.class。但是在本教程中,包含此代码的类和NoteEdit类位于同一个apk中。 我想知道如果活动在另一个apk中,是否可以使用相同的构造函数。

系统类当然可以访问,但它们似乎位于jar文件android.jar中。 所以似乎有一种方法可以直接访问jar文件中的类,我想知道是否有办法访问其他apk中的direclty类。

1 个答案:

答案 0 :(得分:0)

我有一些示例代码供您使用。 在这里,您可以启动HTC智能手机的时钟应用程序

  Intent i = new Intent(Intent.ACTION_VIEW);
  i.setComponent(new ComponentName("com.htc.android.worldclock",
      "com.htc.android.worldclock.WorldClockTabControl"));
  startActivity(i);
相关问题