我在JAVA中创建了一个基于swing的应用程序,它使用了一些加密技术.但是javax.crypto.KeyGenerator.getInstance("AES","BC")给出了异常:
java.security.NoSuchProviderException: JCE cannot authenticate the provider BC
at javax.crypto.SunJCE_b.a(DashoA13*..)
at javax.crypto.KeyGenerator.getInstance(DashoA13*..)
Run Code Online (Sandbox Code Playgroud)
那么问题是什么?
我在标头中设置cookie并使用此标头调用WebView.loadUrl()但它(标头中的Cookie)将无法在除4.4之外的任何Android设备上运行.我在Android版本4.2,4.3,4.4,5.0和5.1上测试了它.
webView = (WebView) findViewById(R.id.web_view);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
HashMap <String, String> extraHeaders = new HashMap<String, String>();
extraHeaders.put("Cookie", "{cookie value}");
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url){
view.loadUrl(url, extraHeaders);
return false;
}
});
webView.loadUrl(url, extraHeaders);
Run Code Online (Sandbox Code Playgroud) recorder = new MediaRecorder();
camera.unlock();
recorder.setCamera(camera);
recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setProfile(CamcorderProfile.get(currentCamType,CamcorderProfile.QUALITY_HIGH));
recorder.setOutputFile(/*path of output file*/);
recorder.prepare();
recorder.start();
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,当调用recorder.start()时,预览会被更改(获得拉伸)但我没有通过MediaRecorder.setPreviewDisplay()设置媒体记录器的预览显示.创建表面视图时,我曾使用过camera.setPreviewDisplay().我认为上面代码中的recorder.setProfile()负责拉伸视频.
我创建了一个应用程序,它在Service.onStartCommand()执行方法时显示Notification,并在Service.onDestroy()调用时隐藏通知.它适用于正常调用startService()和stopService().
服务代码:
@Override
public IBinder onBind(Intent intent)
{
return null;
}
@Override
public void onCreate()
{
super.onCreate();
nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
//Some code here
showNotification();
return START_NOT_STICKY;
}
@Override
public void onDestroy()
{
super.onDestroy();
nm.cancel(R.string.service_started);
}
Run Code Online (Sandbox Code Playgroud)
问题:当我的服务被android OS()销毁时(如果onDestroy()没有被调用),则通知不会被删除.那么当Android OS本身销毁Service时如何删除通知?
为什么要使用Activity Context而我们可以使用Application Context来加载和访问资源?意味着如果我使用Application Context而不是Activity Context则不会发生异常,那么为什么要使用Activity Context呢?
例子:
在下面的示例中,如果我在活动onCreate() 中使用getApplicationContext()而不是“ this ”指针,它可以正常工作,没有任何异常。
Button button = new Button(getApplicationContext());
Run Code Online (Sandbox Code Playgroud) 如何在下面的场景中调用所有类的print*()意味着在main()方法中调用A的printA(),B的printB()和C的printC().
class A
{
public void printA(){System.out.println("A.printA()");}
}
class B extends A
{
public void printB(){System.out.println("B.printB()");}
}
class C extends A
{
public void printC(){System.out.println("C.printC()");}
}
class DemoInheritence
{
public static void main(String[] str){
printIt(new A());
printIt(new B());
printIt(new C());
}
public static void printIt(A a) {
//Here I wants to call A's printA(), B's printB() and C's printC()
//So how can I do this
}
}
Run Code Online (Sandbox Code Playgroud) 我想创建一个即使我的应用程序不在前台(To Toast)也始终可见的视图.此外,我还可以在任务完成时隐藏此视图.例如:类似于android 4.0中CPU使用率的视图,它在设备左上角的所有屏幕上都可见
如何检查视频文件是否有效而不检查其扩展名(.mp3或.3gp等).是否支持设备支持SD卡上的视频文件检查?
在Android 4.0及更高版本中是否有任何验证视频文件的API?
我的场景:下载后我在VideoView上播放视频,下载成功后从本地SD卡播放.下次当请求相同的视频,然后检查SD卡,如果找到,然后开始播放(在这种情况下没有下载).但有时网络错误或app kill中断下载(在这种情况下视频文件未完全下载),因此下载的文件已损坏,VideoView无法播放此文件.那么如何检测这个损坏的文件.
如何使用 ManagedQuery() 从 Android 中的特定文件夹中获取所有音频文件。表示 ManagedQuery() 中的 where 子句应该是什么来过滤 Cursor 结果。
代码是:
String[] proj = { MediaStore.Audio.Media._ID, MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.DISPLAY_NAME, MediaStore.Audio.Media.DURATION };
Cursor cursor = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,proj, /*where clause here*/, null, null);
Run Code Online (Sandbox Code Playgroud) 我有一些哈希标签,TextView以'#'开头
示例:"#one#two Hello World #three".
我希望这些哈希标签可单独点击并打开一个活动并在该活动中获取此文本.
因此,这些哈希作为链接工作并打开一个活动.标签也不固定意味着可以是任何文本.同时将哈希标记的颜色更改为红色,其余标记的颜色将为黑色