发现在一个程序里面的各个活动间, 用Intent激活是很容易的,
但再写一个程序来激活之前程序的各个活动就总是说找不到活动了.
谁能说说是什么原因....又或者直接给个成功调用的例子.

解决方案 »

  1.   

    程序A来启动程序B里的一个activity?
      

  2.   

    通过隐式intent调用方法实现,需要在被调用的activity的manifest文件中添加
    <intent-filter>
    <action android:name="com.example.project.SHOW_ACTIVITY" />
    <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>在StartActivity(it)之前,设定该intent对应的action(com.example.project.SHOW_ACTIVITY)
      

  3.   

    其实没有一个是正解
    我敢肯定都是没实际写过  程序A来启动程序B里的一个activity 的例子
      

  4.   

    Intent mIntent = new Intent( ); 
      ComponentName comp = new ComponentName("包名", "类名");  
      mIntent.setComponent(comp); 
      mIntent.setAction("android.intent.action.VIEW");
      startActivity(mIntent);
    类名为程序的activity,可以给mIntent设置flag,一般是Intent.FLAG_ACTIVITY_NEW_TASK
      

  5.   

    成功的写过一个demo,用来启动愤怒的小鸟,哈哈,设备的桌面上就看不到愤怒的小鸟了
      

  6.   

    程序A来启动程序B里的一个activity
    我是指A和B两个程序都是你写的....
    其中B的写法才问题的关键....
    而书上通常只说A的写法, 以及在A内部各个活动的之间的激活本以为android学起来会很轻松, 以为照着书上学就对了. 
    但现在发现每一步都是一个坎, 进展非常缓慢....
    android居然连个文件选择对话框都没有, 于是我想写一个, 
    于是要求能让别人用Intent就能激活我的文件选择器
    这就是本贴问题的来源....
    等我写好后会共享源码出来, 让后来人不必像我这样一步一个坎走过来.... 
      

  7.   

    还有一种方法
    A程序需要调用B的地方:
    Intent mWifiIntent = new Intent(“android.action.view”);//intent里的内容自己定义
    mWifiIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mContext.startActivity(mWifiIntent);B程序的配置文件AndroidManifest.xml,需要启用的activity里添加
    <intent-filter>
        <action android:name="android.action.view" />
    </intent-filter>
      

  8.   

    mWifiIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    这个很关键
      

  9.   

    文件选择器终于做好了,虽然非常简陋...
    http://download.csdn.net/source/3171544
    我想无论是参考,还是在测试中需要选择文件,都是有点价值的.本贴的正解是, 活动在AndroidManifest.xml中必须添加属性android:exported="true"
    <activity android:name="FileSelector" android:exported="true">
    这样才能把活动供给其他应用程序使用.
      

  10.   


    android:exported
    Whether or not components of other applications can launch the target activity
    through this alias — "true" if they can, and "false" if not.
    If "false", the target activity can be launched through the alias only by
    components of the same application as the alias or applications with the same user ID.其他应用程序的组件是否可以通过别名载入目标activity — "true"表示可以,"false"表示不可以。如果"false",目标activity只可以被别名的同一或者拥有相同用户ID的应用程序组件通过别名载入。我的代码里没有加这个也能够调用的
      

  11.   


    你能把你的例子源码发给我看一下么? [email protected]
      

  12.   

            Button showActivity = (Button)this.findViewById(R.id.Button02);
            showActivity.setOnClickListener(new Button.OnClickListener() {

    @Override
    public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent showIntent = new Intent("intent.show.another.activity");
    startActivity(showIntent);
    }
    });        <activity android:name=".main_activity"
                      android:label="@string/app_name">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
                <intent-filter>
                 <action android:name="intent.show.another.activity" />
                <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
            </activity>
      

  13.   

    你到哪个activity是android.intent.category.LAUNCHER这个类别吗?
      

  14.   

    啊....是我错了
    试了一下不设置 android:exported="true" 也是可以的.
    搞不懂当初为什么会不行了...
      

  15.   

                    Intent intent = new Intent();
                    intent.setClassName(this, "全路径");//包名+类名
    startActivity(intent);