implement signalA in Android project - java

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.

Related

Android: error: cannot find symbol packages.add(new MyAppPackage())

Please HELP!!
I'm working on an app in react-native that involves using a native Calendar module. I'm trying to register this module with react native and I keep getting this error.
This is how I've registered the module in MainApplication.java:
#Override
protected List<ReactPackage> getPackages() {
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider));
packages.add(new MyAppPackage());
return packages;
}
This is the MyAppPackage.java file I've created using the tutorial here, https://reactnative.dev/docs/native-modules-android#register-the-module-android-specific.:
package com.chowtime; // replace your-app-name with your app’s name
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class MyAppPackage implements ReactPackage {
#Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
#Override
public List<NativeModule> createNativeModules(
ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new CalendarModule(reactContext));
return modules;
}
}
Note: This app was previously created using the managed-workflow on expo and was ejected to the bare workflow. This is the directory for the relevant files:
I came across this same error. It seems like the docs on how to create/use native modules in react native are missing a step.
In the MainApplication.java file you need to import 'MyAppPackage'.
import com.your-app-name.MyAppPackage;
Without importing it the 'MainApplication' file it won't know what MyAppPackage is referring to hence the cannot find symbol error.
Is this as simple as an import problem?
I noticed your MyAppPackage class is defined here:
package com.chowtime; // replace your-app-name with your app’s name
But your MainApplication error message seems indicate a sub-package, specifically "chowtime.chowtime". Did you mean for both chowtimes?
com.chowtime.chowtime.MainApplication

Why is 'subscribe' function not registering? RxJava Android Studio

I'm writing code for a splash screen as part of a project but when I am trying to use RxJava all the other functions are working fine until I get to 'subscribe' which isn't registering so I'm wondering am I missing a library I didn't import or something?
The error message I get when trying to run is: 'Cannot resolve method 'subscribe'. I've tried asking the tutorial creator, as well as looking at the top relevant questions about the 'subscribe' function on StackOverflow and even looking at the full list of methods in the Completable library but I can't find a solution so I'm really desperate, please help
These are my dependencies:
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.20'
My Code:
package codebymech.fyprideshareapp;
import androidx.appcompat.app.AppCompatActivity;
import android.app.Notification;
import android.os.Bundle;
import android.widget.Toast;
import java.util.concurrent.TimeUnit;
import io.reactivex.Completable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Action;
public class Activity_SplashScreen extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
delay_Splash();
}
private void delay_Splash() {
Completable.timer(delay: 5, TimeUnit.SECONDS,
AndroidSchedulers.mainThread())
.subscribe(new Action() {
#Override
public void run() throws Exception {
Toast.makeText(Activity_SplashScreen.this, "!! Splash Screen Finished", Toast.LENGTH_SHORT).show();
}
});
}
}
Part of tutorial where the code is from:
https://youtu.be/144TuYxEu2M?t=489
You have to remove delay: . This is not possible in Java. If you look at the video, you see a delay: in given method, but it is added by the IDE (IntelliJ) in order to give you a hint, which parameter you are currently editing.
Import
import io.reactivex.Completable;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
Java8
Completable.timer(5, TimeUnit.SECONDS,
Schedulers.trampoline())
.subscribe(() -> {
System.out.println("x");
});
Java7
Completable.timer(5, TimeUnit.SECONDS,
Schedulers.trampoline())
.subscribe(new Action() {
#Override
public void run() throws Exception {
System.out.println("x");
}
});

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.

Categories

Resources