2 * Copyright (C) 2009 ZXing authors
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.google.zxing.client.android.share;
19 import android.app.ListActivity;
20 import android.app.ProgressDialog;
21 import android.content.DialogInterface;
22 import android.content.Intent;
23 import android.os.Bundle;
24 import android.provider.Browser;
25 import android.view.View;
26 import android.widget.ListView;
27 import com.google.zxing.client.android.R;
29 import java.util.ArrayList;
30 import java.util.List;
32 public final class AppPickerActivity extends ListActivity {
34 private final List<String[]> labelsPackages = new ArrayList<String[]>();
35 private DialogInterface dialog;
38 protected void onCreate(Bundle icicle) {
39 super.onCreate(icicle);
40 dialog = ProgressDialog.show(this, "", getString(R.string.msg_loading_apps), true, true);
41 if (labelsPackages.isEmpty()) {
42 new LoadPackagesAsyncTask(this).execute(labelsPackages);
44 // otherwise use last copy we loaded -- apps don't change much, and it takes
45 // forever to load for some reason
49 protected void onListItemClick(ListView l, View view, int position, long id) {
50 if (position >= 0 && position < labelsPackages.size()) {
51 String url = "market://search?q=pname:" + labelsPackages.get(position)[1];
52 Intent intent = new Intent();
53 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
54 intent.putExtra(Browser.BookmarkColumns.URL, url);
55 setResult(RESULT_OK, intent);
57 setResult(RESULT_CANCELED);
62 DialogInterface getProgressDialog() {