草庐IT

android - Android 中的底部共享表

在Android应用程序中共享数据时,我看到多个应用程序使用底部工作表(例如GoogleI/O2015)来指示应用程序执行操作,而不是包含应用程序来处理您的Intent的标准对话框。例如:IntentshareIntent=newIntent(Intent.ACTION_SEND);shareIntent.setType("text/plain");shareIntent.putExtra(Intent.EXTRA_TITLE,"Sometitle..");shareIntent.putExtra(Intent.EXTRA_TEXT,"Sometext");startActivity(

android - 如果未安装 Intent,请下载应用程序

我知道我已经看到了一种调用Intent的方法,如果它不存在,该函数将重定向到市场以下载具有Intent的应用程序。现在我检查Intent是否存在,但我不知道如何将用户指向要下载的资源。提前致谢 最佳答案 检查某个Intent是否可用:StringintentToCheck="com.google.SCAN";//canbeanyotherintentfinalPackageManagerpackageManager=getPackageManager();finalIntentintent=newIntent(intentToChe

android - 从我的应用程序搜索 Youtube 应用程序中的特定字符串

我有一个按钮,当我点击它时,我想调用Youtube应用程序并搜索预定义的字符串(搜索字符串是不变的,我的意思是Youtube应用程序将自动显示结果)。我知道为了搜索channel,我们把Intentintent=newIntent(Intent.ACTION_VIEW);intent.setData(Uri.parse("http://www.youtube.com/user/channel"))但是如何搜索特定视频(常量字符串)呢?感谢您的帮助。 最佳答案 试试这个IntentForSearchonYoutube:Intentin

java - 使用文件路径在图库中打开图像

我的数据库中存储了一个图像文件路径。现在使用它我想在我的画廊中打开SD卡中的图像。我怎样才能做到这一点。我已经看到Uri的方法并使用了这个方法,但是我收到了错误Filefile=newFile(filename);Uriuri=Uri.fromFile(file);Intentintent=newIntent(Intent.ACTION_VIEW,uri);intent.setType("image/*");startActivity(intent);/**replacewithyourownuri*/如何解决,04-2008:42:23.516:E/AndroidRuntime(16

android - IntentService 的意外行为

我在我的代码中使用了IntentService而不是Service,因为IntentService在onHandleIntent(Intentintent)中为我创建了一个线程,所以我不必在我的服务代码中自己创建一个Thead。我预计同一个IntentSerivce的两个Intent将并行执行,因为在IntentService中会为每个发明生成一个线程。但我的代码证明这两个Intent是按顺序执行的。这是我的IntentService代码:publicclassUpdateServiceextendsIntentService{publicstaticfinalStringTAG="H

android - 如何控制Android返回堆栈

假设我有A->B->C->D->E在android返回堆栈中。我希望能够返回到以下其中一项:A->B->CA->BA我怎样才能做到这一点?希望不要强制点击后退按钮。 最佳答案 使用来自Android官方开发者页面的图像和信息tasksandbackstack您可以看到,在启动Activity的所有其他方式中,您只能使用Intent标志中的FLAG_ACTIVITY_CLEAR_TOP来确保此类行为。您的常规后退按钮如下:但是,当您指定此标志时,您会得到所需的行为,如thissource中的示例所示:considerataskcons

Android:注销时清除所有 Activity 的完美方法?

我的应用程序中的所有Activity都有注销按钮,用户可以从任何Activity中注销。我想将用户发送到登录Activity而不显示以前的Activity。为此,我正在使用:以下是注销方法删除sessionpublicvoidlogoutUser(){//clearingalldatafromsharedPreferenceseditor.clear();editor.commit();Intentintnt=newIntent(contxt,LoginActivity.class);//ClosingalltheActivitiesintnt.addFlags(Intent.FLAG

android - 在启动外部 Activity/Intent 后返回应用程序时显示应用程序主菜单/主屏幕

我正在通过我的应用程序启动Android电子市场,以使用以下代码搜索类似产品:Intentintent=newIntent(Intent.ACTION_VIEW,Uri.parse("http://market.android.com/search?q=pub:\"sometxt\""));c.startActivity(intent);这对于展示类似的产品效果很好。但是,如果我在市场上按下主页按钮,当我重新打开应用程序时,它仍然会显示市场结果。在这种情况下,我想转到主菜单。有解决办法吗? 最佳答案 抱歉,FLAG_ACTIVITY

android - 如何启动和 App Chooser

此应用程序的任务是隐式激活一个单独的应用程序来查看URL“http://www.google.com”。因此,AppChooser应该会出现,让我在至少两个浏览器之间进行选择:默认浏览器会显示www.google.com网站,另一个简单的“浏览器”只会显示url。问题是-当我使用隐式Activity时,应用选择器没有出现。可能我为第二个“简单浏览器”编写了错误的Intent过滤器。privatevoidstartImplicitActivation(){Log.i(TAG,"EnteredstartImplicitActivation()");//TODO-Createabaseint

android - 为什么 Android 会忽略通知的创建?

我有代码,但它不起作用,所以我请任何人帮助我。关于这个具体问题的信息非常少。主ActivitypublicclassMainActivityextendsActivity{publicfinalintPENDING_INTENT_ID=8;@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);Buttonclickity=(Button)findViewById(R.id.alarm_button);cl