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.Intent;
22 import android.os.Bundle;
23 import android.provider.Browser;
24 import android.view.View;
25 import android.widget.ListView;
26 import com.google.zxing.client.android.R;
28 import java.util.ArrayList;
29 import java.util.List;
31 public final class AppPickerActivity extends ListActivity {
33 private final List<String[]> labelsPackages = new ArrayList<String[]>();
34 private ProgressDialog dialog;
37 protected void onCreate(Bundle icicle) {
38 super.onCreate(icicle);
39 dialog = ProgressDialog.show(this, "", getString(R.string.msg_loading_apps), true, true);
40 if (labelsPackages.isEmpty()) {
41 new LoadPackagesAsyncTask(this).execute(labelsPackages);
43 // otherwise use last copy we loaded -- apps don't change much, and it takes
44 // forever to load for some reason
48 protected void onListItemClick(ListView l, View view, int position, long id) {
49 if (position >= 0 && position < labelsPackages.size()) {
50 String url = "market://search?q=pname:" + labelsPackages.get(position)[1];
51 Intent intent = new Intent();
52 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
53 intent.putExtra(Browser.BookmarkColumns.URL, url);
54 setResult(RESULT_OK, intent);
56 setResult(RESULT_CANCELED);
61 ProgressDialog getProgressDialog() {