How to show ActionBar in a CordovaActivity - ibm-mobilefirst

Using Worklight 6.2 and the new ActionSender API, I'd like to show the actionbar in the main CordovaActivity of my hybrid app.
That's in order to manage it by Javascript code, through the new API.
The problem is that getActionBar() returns null, even adding the holo theme and a layout to this activity.
Does somebody have a snippet of code to show me the how to do that?
Regards
Giuseppe

The blog post has been revised to include the missing pieces. Follow the instructions again, it will now work.
The missing pieces were related to the below:
Make sure that in your AndroidManifest, the activity doesn't have a theme without a title bar:
<activity
android:name=".HybridActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="sensor"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
^ last line should be removed.
>
Add a preference to Cordova configuration (res/xml/config.xml) to make the title bar be shown:
<preference name="ShowTitle" value="true" />

Related

RecyclerView onItemClick effect in L

Maybe this question has been asked before, but I couldn't find a precise answer. I have implemented the RecyclerView widget as a list in my L test application and I want to get the 'material effect' when you click on an item form the list. I implemented an onClickListener in my ViewHolder creation and set the attribute
android:background="?android:attr/selectableItemBackground"
as a background to my list item layout (to the parent).
But none of this worked. When I click on the items NOTHING happens'. There is no effect, holo, material, none... Please point out if I am doing something wrong here... Thx
Sandra's answer didn't work for me. I needed one more property in my list item layout:
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
Note: if you get an error when pasting in the last line, then your android app is set on version 10 or below. Just right click on the error in Android Studio and set it so it will create a v11 version of your layout as well. Then, in the original layout, make sure to delete
android:background="?android:attr/selectableItemBackground"`
This is because the animation isn't supported in v10 versions of android or lower. With these two layout files set up, the animation will correctly show in v11+ versions of Android and of course it won't be shown in lower versions.
(or just increase the minSdkVersion version of your app to higher than 10)
I made a silly mistake and did not put
android:clickable="true"
android:focusable="true"
to my list item layout. I think this was not required pre L, but it doesn't matter because that was the problem in this case.
android:clickable="true"
android:focusable="true"
these lines are no longer used. just adding
android:background="?android:attr/selectableItemBackground"
working for click effect.

Camera.open() is not working android

I am trying to write a custom camera application in android.
For that I need to open the camera application.
for that i am tring following code..
Camera camera = Camera.open();
but is showing error like
method open undefined for type Camera
i did as suggested here http://developer.android.com/reference/android/hardware/Camera.html#open(int)
any suggestion..
Thanks,
Ravindra Gupta
You most likely imported the wrong camera class at the top of your source file, which is android.graphics.Camera.
You need android.hardware.Camera instead.
Thanks
I think you have not added the camera permission. See below - you need to add this in your manifest;
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
Check your imports. I had a similar problem and the Camera object Eclipse chose for me was: import android.graphics.Camera; instead it should be: import android.hardware.Camera;
If none of the above work:
check to see if you are requesting camera permission manually. Newer Android permissions (API > 23) are set at runtime, not install time.
See: https://developer.android.com/training/permissions/requesting.html
Please create a variable like this:
android.hardware.Camera camera ;
and then try open method :
camera = camera.open();
// this is working on my android studio
I have Faced the same problem till i reached that older versions of android will work properly until Android Marshmallow so it needs a runtime permission in order to proceed and show the camera ...
you can read about it in this link https://developer.android.com/training/permissions/requesting.html
for me i used a 3rd party library to do all this stuff for me from this link and all resolved ..
https://android-arsenal.com/details/1/2804
Hope it helps
I have faced a lot of issues while using integrating camera native/camera2 api. The code was bulky. To avoid complexity and compatibility issues google provide new CameraX api in new android jetpack library. See the google provided documentation https://developer.android.com/training/camerax. There is also a Kotlin based library i found on github https://github.com/robertlevonyan/CameraXDemo. You can get more clearity with less code.
Waged right!!!
A permission request is required. And I found the right code. he works.
I advise you to look at this article to initially connect the camera:
https://habr.com/ru/post/112272/
enter image description here
if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this, new String[] {Manifest.permission.CAMERA}, 15); }

How to use the Common/StandardStyles in a C# WinRT project?

I'm working on a WinRT project in C#
I wanted to use things like: {StaticResource EditAppBarButtonStyle}
this is defined in Common/StandardStyles.xaml
but when I try to compile my project I get the error that the resource could not be resolved.
I guess I need to add the Common/StandardStyles.xaml but I dont know how
Solution: I just needed to remove the <!-- ... --> in the Common/StandardStyles.xaml
A few years too late, but maybe helpful to someone else who stumbles on this question from a bing search: For a Windows 8.1 app, that's not how you do it anymore.
Since most people never used most of the styles in StandardStyles.xaml, this file was removed for performance reasons. In Windows 8.1, you use an AppBarButton like
<AppBarButton Icon="Edit" Label="Edit" />
Info taken from this blog post right here

Struts Tiles ActionError

Good Afternoon in my timezone.
I am using Struts tiles framework to build a Web app, and i am facing a very strange problem.
I am running out of time to finish the work and if i am not able to fix this problem i will give up of using Tiles in this project.
My Tiles configuration is very simple.
In my struts-config.xml i insert the following code:
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor" />
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config" value="/WEB-INF/tilesdefs.xml" />
<set-property property="moduleAware" value="true" />
</plug-in>
In the tilesdefs.xml i have this simple code :
<component-definitions>
<definition name="programarRutasTile" path="/programarRutas.jsp">
<put name="menu" value="menu.jsp"/>
<put name="tab" type="String" value="2"/>
</definition>
</component-definitions>
And in the jsp "programarRutas.jsp" i have those three Tiles code lines:
<tiles:insert name="menu">
<tiles:put name="tabSelected"><tiles:getAsString name="tab"/></tiles:put>
</tiles:insert>
The menu.jsp is simple html code that make use of the tabSelected attribute passed in the programarRutas.jsp (code above).
I already try to run with all the menu.jsp page commented and the error persist.
So now will explain the error:
When i run the application and the ActionForm validate method do not find any error, the application runs normally, if the ActionForm validate method finds errors and fullfill the ActionErrors array , then the application throws the following exception :
java.lang.NullPointerException at org.apache.struts.tiles.taglib.InsertTag.processName...
The only way i can run when the application finds errors is commenting the Tiles lines code in the programarRutas.jsp
//<tiles:insert name="menu">
// <tiles:put name="tabSelected"><tiles:getAsString name="tab"/></tiles:put>
//</tiles:insert>
That way there is no throw exception. By those symptoms that i describe it looks like that there could be a problem in some configuration file, but i do not no for sure.
Is there anybody that could help me ???
Best regards.
Thanks in advance
The input should be the tile def, not a direct link to the JSP.

activities perspective issue

I created a sample plugin which needs to hide the java perspective. For that I used activities. The problems what happends is,it is hiding from the perspectives,but it is there still in the (recent opened perspectives). How can I hide it from there also? Following is my code.
<extension
point="org.eclipse.ui.activities">
<activity
id="com.example.activities.hideperspective"
name="Hide Perspective">
</activity>
<activityPatternBinding
activityId="com.example.activities.hideperspective"
isEqualityPattern="false"
pattern="com.example.activities.hideperspective/org.eclipse.jdt.ui.JavaPerspective">
</activityPatternBinding>
Is this the right way what I have implemented? One more thing, This hiding of perspective I am calling when I click a Button on the toolbar. That the that buttons location is also getting changed. some kind of refresh on the toolbar.
I have attached the screenshot as well.
The activityPatternBinding is plugin.id/perspective.id, where the plugin.id is the ID of the plugin that contributed the perspective, not com.example.activities.hideperspective. Also, it does look like an equality pattern.
Also, activities will show something (like a perspective) if any activity that points to that perspective is enabled. So setting one activity to enabled=false might not get rid of the perspective.
And finally, activities won't shut a perspective that is already open. It just removes it from the "Open Perspective" dialog/shortcuts.