English 中文(简体)
从代码上安装
原标题:start installed app from code
  • 时间:2011-04-30 19:54:20
  •  标签:
  • android

Hallo,我写了一封信,我想把一张草图混为一谈,以引出一些东西,把档案或转回我。 此时此刻,镜头可以储存视频、图像、感官数据,......我还要增加储存包裹的能力。 我发现这部法律。

    final Intent intent = new Intent(Intent.ACTION_MAIN, null);

    intent.addCategory(Intent.CATEGORY_LAUNCHER);

    final ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.fuelgauge.PowerUsageSummary");

    intent.setComponent(cn);

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    startActivity( intent);    

但i dont知道如何开办篮子(从市场来看)。 我还需要通向挽救的情景的道路。 还是有其他方式? 或公开来源?

问候......

最佳回答

简图书不是你的申请?

为了启动另一个方案,你需要知道它使用的意向过滤器,或一揽子名称。 篮子开发商将能够向您提供这一信息(如果他们愿意分享)。

现在,从另一处获取数据时,如果开发商这样做,那就只能让你们回到。 应由开发商决定哪些活动回报(如果有的话)。 因此,如果你想与一份具体<><>>>>申请结合起来,那么你最好与开发商联系,并讨论两者的相互关系。 另一方面,如果你执行自己的一揽子计划,那么你就可以把自己纳入。

问题回答

你们需要发现这一意图可由系统处理。

public static boolean canHandleIntent(final Context context, final Intent intent) {

    if (intent != null) {
        final PackageManager pm = context.getPackageManager();
        if (pm != null) {
            if (pm.queryIntentActivities(intent, 0).size() > 0) {
                return true;
            }
        }
    }

    return false;
}

If that returns false you should prompt the user to download the app from the market. Call,

//Market.getViewPackageOnMarket("org.otherapp.sketchapp");

public class Market {

    public static final String Application_BaseMarketUri = "market://details?id=";

    public static final Intent getViewPackageOnMarket(final String package_name) {
        final Intent result = new Intent(Intent.ACTION_VIEW);
        result.setData(Uri.parse(Application_BaseMarketUri + package_name));
        return result;
    }
}

你们也需要开始使用 活动 因此,在您的发起活动中,你需要补充这些内容。

public class MyKillerAppActivity extends Activity {

    // Declare constant for the activity result.
    public static final int ACTIVITYRESULT_GETSKETCH = 1;

    // Call the activity ....
    public void someMethod() {
       startActivityForResult(intent, ACTIVITYRESULT_GETSKETCH);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(resultCode == RESULT_OK) {
            if(requestCode == ACTIVITYRESULT_GETSKETCH) {
                handleGetSketchResult(data);

            } /* Handle other results if you need to. */
        }
    }
}

这是一种口号,但还有人! 你们需要解释数据来源。 我不知道这种格式是用篮子对你进行回顾,但这里就是一个如何从美术馆获取数据的例子。 该美术馆把你带回一个内容提供者所在地,以装上用户所收集的形象。 该法典从内容提供者处查找档案,然后打开档案,将其装入一个供使用的比图。

public static Bitmap onActivityResult_getImage(Context context, Intent data) {
    Bitmap result = null;
    Uri dataUri = data.getData();
    final String filePath = findPictureFilePath(context, dataUri);
    if(filePath != null) {
        result = BitmapFactory.decodeFile(filePath);
    }
    return result;
}

private static String findPictureFilePath(Context context, Uri dataUri) {
    String filePath = null;
    final String[] projection = { MediaStore.Images.Media.DATA };
    Cursor cursor = null;
    try {
        cursor = context.getContentResolver().query(dataUri, projection, null, null, null);
        int data_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        if(cursor.moveToFirst()) {
            filePath = cursor.getString(data_index);
        }
    } finally {
        if(cursor != null) {
            cursor.close();
        }
    }

    return filePath;
}




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签