我正在开发一个应用程序,用于barcode在扫描后获取项目的产品信息barcode.
我不希望用户ZXing barcode单独安装应用程序,因此我将ZXing代码嵌入到我的项目中.所以我能够获得barcode ID number.
我想要得到的产品信息像名称,生产厂家,价格等使用使用条形码编号谷歌搜索API购物.
这是我用过的代码
public class JSONExampleActivity extends Activity {
TextView httpStuff;
DefaultHttpClient client;
JSONObject json;
final static String URL = "https://www.googleapis.com/shopping/search";
String upc = "/v1/public/products?country=US&q=691464717759&restrictBy=gtin=691464717759";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
httpStuff = (TextView) findViewById(R.id.tvHttp);
client = new DefaultHttpClient();
new Read().execute("items");
}
public JSONObject products(String upc) throws ClientProtocolException, IOException, …Run Code Online (Sandbox Code Playgroud) 我正在开发一个任务管理器应用程序
在该应用程序中,我向用户显示每个应用程序旁边正在运行的应用程序列表和终止按钮.当用户按下kill按钮时,相应的活动将被终止并且我被使用
activitymanager.killbackgroundprocesses(packageName)
Run Code Online (Sandbox Code Playgroud)
我创建了另一个名为服务通知的应用程序,用户可以通过单击按钮"启动服务"和按钮"停止服务"来启动和停止服务.然后在运行我的任务管理器应用程序之前,我从服务通知应用程序启动了服务.所以这个活动显示在我的任务管理器应用程序中.
但是,当我杀死该活动时,它会从列表中消失,然后再次出现,因为服务正在重新启动.那么我如何杀死服务呢?
我使用startService和onCreate来启动服务并显示一些通知和stopService以及onDestroy来停止服务...