Qt Android notification, Cannot set image - java

I am making an Android testapp in Qt using Java libraries for the notifications. Following the Qt Notifier example im trying recreate the same notification for starters but for some reason this line does not work:
m_builder.setSmallIcon(R.drawable.icon);
it says:
java:77: error: error: package R does not exist
I have tried adding:
import java.lang.Object;
import android.R.drawable;
I have also tried:
m_builder.setSmallIcon(android.R.drawable.icon);
but this gives me the error:
java:77: error: error: cannot find symbol
So I have checked the Qt Notifier app and I dont think i have made any mistakes but for some reason it won't work.
My question is: How do I set this icon correctly?
Here is the full piece of code:
package org.qtproject.qt5.example;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import java.lang.Object;
import java.lang.Throwable;
import java.io.Writer;
import java.io.StringWriter;
import java.io.PrintWriter;
import android.R.drawable;
public class NotificationClient extends org.qtproject.qt5.android.bindings.QtActivity
{
private static NotificationManager m_notificationManager;
private static Notification.Builder m_builder;
private static NotificationClient m_instance;
public NotificationClient()
{
try {
m_instance = this;
} catch(Throwable t) {
t.printStackTrace();
}
}
public static void notify(String s)
{
try {
if (m_notificationManager == null) {
m_notificationManager = (NotificationManager)m_instance.getSystemService(Context.NOTIFICATION_SERVICE);
m_builder = new Notification.Builder(m_instance);
m_builder.setContentTitle("A message from Qt!");
//m_builder.setSmallIcon(android.R.drawable.icon);
}
m_builder.setContentText(s);
m_notificationManager.notify(1, m_builder.build());
} catch(Throwable e) {
e.printStackTrace();
}
}
}

To fix this error make sure that package name in your java class and your AndroidManifest.xml are the same.
NotificationClient.java:
package com.mypackage;
...
AndroidManifest.xml:
<manifest package="com.mypackage"...
...

The problem for me was because of a wrong configuration in AndroidManifest.xml.
After editing the AndroidManifest correctly and cleaning and rebuilding the project, the problem was solved.

Related

cannot find symbol import com.user.userCom

Trying to create native module for react-native. I have all the dependencies needed and I followed the instructions user com mobile sdk installation
in project/android/build.gradle
allprojects {
repositories {
…
maven {
url 'https://android-sdk.user.com'
}
}
}
in project/android/app/build.gradle
dependencies {
implementation 'com.user:android-sdk:1.0.0'
}
then i created file in project/app/src/main/java/com/my_app/UserComModule.java
package com.my_app;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import java.util.Map;
import java.util.HashMap;
import com.user.UserCom;
public class UserComModule extends ReactContextBaseJavaModule {
private static ReactApplicationContext reactContext;
#Override
public void onCreate() {
super.onCreate();
new UserCom.Builder(
this,
"api_secret", //your api secret key generated in User.com webpanel details
"https://<your_app_subdomain>.user.com"
)
.trackAllActivities(true) // false by default
.openLinksInChromeCustomTabs(true) // true by default
.setCustomTabsBuilder(getCustomTabsBuilder())
.build();
}
}
When i run i get: cannot find symbol import com.user.UserCom;
You're importing UserCom, and that module is not availabe, as you've mentioned you had created the file UserComModule in that directory, either create UserCom class or delete this line from UserComModule
import com.user.UserCom;

getting error in CODEC_ID_MPEG1VIDEO and PIX_FMT_YUV420P

I am trying to create a code which will convert images into video. I have surfed a lot and find some method to do it using javacv. now i am getting variable not found error in these lines.
recorder.setCodecID( CODEC_ID_MPEG1VIDEO);
recorder.setPixelFormat( PIX_FMT_YUV420P);
I have imported all the jar files into my library as well but still getting this error. Some quick help would be appreciated. I have gone through the below link for the importing the javacv into my workspace.
How to Import JavaCV libraries to Android Project
package com.example.photoaday;
import static com.googlecode.javacv.cpp.opencv_core.cvReleaseImage;
import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImage;
import static com.googlecode.javacv.cpp.opencv_highgui.cvShowImage;
import static com.googlecode.javacv.cpp.opencv_highgui.cvWaitKey;
import static com.googlecode.javacv.cpp.opencv_imgproc.CV_GAUSSIAN;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvSmooth;
import com.googlecode.javacv.FFmpegFrameRecorder;
import com.googlecode.javacv.cpp.opencv_core;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class Recordvideo extends Activity {
// #Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.create);
opencv_core.IplImage img = cvLoadImage("/sdcard/folder/img1.jpg");
FFmpegFrameRecorder recorder = new FFmpegFrameRecorder("/sdcard/folder/test.mpeg",200,150);
try {
recorder.setCodecID( CODEC_ID_MPEG1VIDEO);
recorder.setFrameRate(30);
recorder.setPixelFormat( PIX_FMT_YUV420P);
recorder.start();
for (int i=0;i<100;i++)
{
recorder.record(img);
}
recorder.stop();
}
catch (Exception e){
e.printStackTrace();
}
}
}
I assume that your compiler gives error as follows
error: ‘CODEC_ID_MPEG1VIDEO’ was not declared in this scope
error: ‘PIX_FMT_YUV420P’ was not declared in this scope
then solution for error is
change : ‘CODEC_ID_MPEG1VIDEO’ to 'AV_CODEC_ID_MPEG1VIDEO'
change : ‘PIX_FMT_YUV420P’ to 'AV_PIX_FMT_YUV420P'

Cordova cannot find symbol error when build android project with self-built plugin (call for native java code)

I tried to run an android project in Cordova with self-build plugin,
Heres the code in JS and java for the plugin
var cordova = require('cordova');
var Carrier = function() {};
Carrier.prototype.getCarrierCode = function(success, error) {
cordova.exec(success, error, 'CarrierPlugin', 'getCarrierCode', []);
};
var carrier = new Carrier();
module.exports = carrier;
this is the java code:
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Date;
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.CallLog;
import android.content.ContentResolver;
public class CarrierPlugin extends CordovaPlugin{
public static final String TAG = "CarrierPlugin";
public static final String ACTION_GET_CARRIER_CODE = "getCarrierCode";
//public TelephonyManager tm;
#Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
// TODO Auto-generated method stub
super.initialize(cordova, webView);
}
#Override
public boolean execute(String action, CordovaArgs args,
CallbackContext callbackContext) throws JSONException{
callbackContext.success("run it");
return true;
}
}
the error I got is "cannot find symbol :"
the strange thing is that, even if I change the code in the CarrierPlugin.java(delete the JSONException in line 16), it reported the same error.
My Eclipse says, you should import CordovaInterface, CordovaWebView and CordovaArgs.
And you might be missing package declaration as well, depending wherever you want to put your plugin's java files, such as:
package com.yourdomain.etc in the very first line of your Java file.

java.lang.reflect.UndeclaredThrowableException

In my ejb client code
package client;
import com.homeif.HelloWorldHome;
import com.remoteif.HelloWorld;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.awt.image.LookupOp;
import java.util.Properties;
public class HelloClient {
public static void main(String args[]) {
try {
Context initialContext = new InitialContext();
Object object = initialContext.lookup("HelloWorldBean");
System.out.println("Object:-"+object);
HelloWorldHome home =
(HelloWorldHome) PortableRemoteObject.narrow(object,
HelloWorldHome.class);
HelloWorld myHelloWorld = home.create();
String message = myHelloWorld.sayHello();
System.out.println(message);
} catch (Exception e) {
System.err.println(" Error : " + e);
System.exit(2);
}
}
}
I am getting the following error
java.lang.Exception: java.lang.NoSuchMethodError: org.jboss.remoting.Version.getDefaultVersion()
It is in the following line
HelloWorldHome home =(HelloWorldHome) PortableRemoteObject.narrow(object, HelloWorldHome.class);
Why it is so? How can I solve this?
The jar I am using is jboss-remoting-1.4.1.final.jar. But the Version class in it doesn't contain the function getDefaultVersion. Can anyone please tell me the jar file for this?
I added jboss-remoting-4.2.2.GA.jar. that solved the problem

implement signalA in Android project

For several days I have been trying to implement SignalA in my Android-Project.
I've found out that I have to import the 3 Projects (parallel-basic-http-client, SignalA and SignalALongPolling) in Eclipse. After the import of parallel-basic-http-client, I have several errors. It seems that the origin of those errors is in the import statement:
import com.turbomanage.httpclient.AsyncCallback;
In the console, the following statement is listed:
[2013-12-03 09:03:45 - parallel-basic-http-client] WARNING: unable to write jarlist cache file C:\Users\Patrik\workspace\parallel-basic-http-client\bin\jarlist.cache
Below is the complete code for the understanding:
package com.zsoft.parallelhttpclient;
import android.os.AsyncTask;
import android.os.Build;
import com.turbomanage.httpclient.AsyncCallback;
import com.turbomanage.httpclient.AsyncHttpClient;
import com.turbomanage.httpclient.HttpRequest;
import com.turbomanage.httpclient.android.DoHttpRequestTask;
public class DoParallelHttpRequestTask extends DoHttpRequestTask {
public DoParallelHttpRequestTask(AsyncHttpClient httpClient,
AsyncCallback callback) {
super(httpClient, callback);
// TODO Auto-generated constructor stub
}
public void execute(HttpRequest httpRequest) {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
super.execute(httpRequest);
} else {
super.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, httpRequest);
}
}
}
Can anyone help me?
I think there is a problem with the dependencies used by SignalA.
To make it easier to use SignalA I've published it on Maven Central.

Categories

Resources