In Android Manifest I have added all the required permission for geolocation and added the service name as TimeTracking
package com.timetracking;
import android.content.Intent;
import android.os.Bundle;
import com.facebook.react.HeadlessJsTaskService;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.jstasks.HeadlessJsTaskConfig;
import javax.annotation.Nullable;
public class TimeTracking extends HeadlessJsTaskService {
#Override
protected #Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) {
Bundle extras = intent.getExtras();
WritableMap data = extras != null ? Arguments.fromBundle(extras) : null;
return new HeadlessJsTaskConfig(
"TimeTracking", // Use the registered headless Task here
data,
500,
true);
}
}
And in app.js page in react native I have called it.
AppRegistry.registerHeadlessTask('TimeTracking', () => TimeTracking);
but nothing is displaying in console.Please can somebody tell the method to get timeInterval of location.
Thanks in advance.
Related
I'm currently trying to display the percentage of my Ev Via Android Auto. I can't manage to get CarInfo carInfo = getCarContext().getCarService(CarHardwareManager.class).getCarInfo(); to run. I used this in my automotive build.gradle useLibrary 'android.car' and tried importing many things but that didn't help obviously.
This is my first file:
package com.example.aatest4;
import android.car.Car;
import android.car.CarInfoManager;
import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.car.app.CarAppMetadataHolderService;
import androidx.car.app.CarAppService;
import androidx.car.app.CarContext;
import androidx.car.app.Screen;
import androidx.car.app.Session;
import androidx.car.app.hardware.CarHardwareManager;
import androidx.car.app.hardware.info.CarInfo;
import androidx.car.app.validation.HostValidator;
//import android.content.ServiceConnection;
public class HelloWorldService extends CarAppService {
#NonNull
#Override
public HostValidator createHostValidator() {
return HostValidator.ALLOW_ALL_HOSTS_VALIDATOR;
}
public Session onCreateSession() {
return new Session() {
#NonNull
#Override
public Screen onCreateScreen(#NonNull Intent intent) {
CarInfo carInfo = getCarContext().getCarService(CarHardwareManager.class).getCarInfo();
return new HelloWorldScreen(getCarContext());
}
};
}
}
and this my second:
package com.example.aatest4;
//import android.car.Car;
//import android.car.CarInfoManager;
import androidx.annotation.NonNull;
import androidx.car.app.CarContext;
import androidx.car.app.Screen;
import androidx.car.app.model.Pane;
import androidx.car.app.model.PaneTemplate;
import androidx.car.app.model.Row;
import androidx.car.app.model.Template;
public class HelloWorldScreen extends Screen {
//public HelloWorldScreen() {
public HelloWorldScreen(CarContext carContext) {
super(carContext);
}
#NonNull
#Override
public Template onGetTemplate() {
String akku = String.valueOf(50);
Row row = new Row.Builder().setTitle(akku + "% ").addText(akku + "%").build();
return new PaneTemplate.Builder(new Pane.Builder().addRow(row).build()) .setTitle("Akkuanzeige").build();
//Todo: Center?
}
}
When following Cubicoder's modding tutorial for Forge 1.12.2, and creating my first item, the texture for the item will not load. I have double checked all of my code against his code. I have my latest log here. I have my registration handler RegistrationHandler.java down below.
package notacyborg.tutorialmod;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent.Register;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import notacyborg.tutorialmod.util.RegistryUtil;
#EventBusSubscriber(modid = TutorialMod.MODID)
public class RegistrationHandler
{
#SubscribeEvent
public static void registerItems(Register<Item> event)
{
final Item[] items = {
RegistryUtil.setItemName(new Item(), "first_item").setCreativeTab(CreativeTabs.MISC)
};
event.getRegistry().registerAll(items);
}
}
ModelRegistrationHandler.java
package notacyborg.tutorialmod.client;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import notacyborg.tutorialmod.TutorialMod;
import notacyborg.tutorialmod.init.ModItems;
#EventBusSubscriber(value = Side.CLIENT, modid = TutorialMod.MODID)
public class ModelRegistrationHandler
{
#SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
registerModel(ModItems.FIRST_ITEM, 0);
}
private static void registerModel(Item item, int meta)
{
ModelLoader.setCustomModelResourceLocation(item, meta,
new ModelResourceLocation(item.getRegistryName(), "inventory"));
}
}
And my first_item.json model file.
{
"parent": "item/generated",
"textures": {
"layer0": "tutorialmod:textures/items/first_item"
}
}
Any help is appreciated!
Your error log says that it was not able to find the model file of your first_item. Make sure that you have put your first_item.json (model file) in assets/Your-Mod-ID/models/item/first_item.json
In your first_item.json file, line 4 should be:
"textures": {
"layer0": "tutorialmod:item/first_item"
}
Try it out and post an error log too if you encounter any further errors.
I am working on android studio project for the first time and I am using Broadcast Receiver. Whenever I run my application I get an error that my Broadcast File uses or overrides a deprecated Api. Although my project runs fine but I need to know why I am getting this and how to get rid of this error.My broadcast file is as follows:
package com.example.user.offlinemobilefinder;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
public class AlarmActivity extends AppCompatActivity {
MediaPlayer myMediaPlayer = null;
Button btnStop;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_alarm);
Intent intent= getIntent();
final String contact=intent.getStringExtra("contact");
btnStop=findViewById(R.id.stopButton);
myMediaPlayer = MediaPlayer.create(this, R.raw.loudalarm);
final AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM);
audioManager.setStreamVolume(AudioManager.STREAM_ALARM, maxVolume,AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
myMediaPlayer.start();
btnStop.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
myMediaPlayer.stop();
SmsManager smsManager = SmsManager. getDefault();
smsManager.sendTextMessage(contact, null, "Alarm Stoped", null, null);
}
});
}
}
Thanks in advance for help.
AndroidStudio should tell you which method is deprecated. You can then go to the documentation for that method on developer.android.com and there should be a note telling you what to use instead.
Trying to create native module for my react-native android application. Codes below is my native java to render / display map using mapsforge library.
I need help please, I need to have a function that returns the instance of the application and if possible it is inside the class that extends LinearLayout. I need to call the function as parameter for the AndroidGraphicFactory.createInstance(InstanceOfTheApplication). You think what I am doing is possible?
import android.content.Context;
import android.location.LocationManager;
import android.os.Environment;
import android.os.StrictMode;
import android.widget.LinearLayout;
import org.mapsforge.core.model.LatLong;
import org.mapsforge.map.android.graphics.AndroidGraphicFactory;
import org.mapsforge.map.android.layers.MyLocationOverlay;
import org.mapsforge.map.android.util.AndroidUtil;
import org.mapsforge.map.android.view.MapView;
import org.mapsforge.map.datastore.MapDataStore;
import org.mapsforge.map.layer.cache.TileCache;
import org.mapsforge.map.layer.renderer.TileRendererLayer;
import org.mapsforge.map.model.MapViewPosition;
import org.mapsforge.map.reader.MapFile;
import org.mapsforge.map.rendertheme.InternalRenderTheme;
import java.io.File;
public class CustomMapView extends LinearLayout {
private Context context;
private MapView mapView;
private TileCache tileCache;
private TileRendererLayer tileRendererLayer;
private MyLocationOverlay myLocationOverlay;
private MapViewPosition mapViewPosition;
private LocationManager locationManager;
private static final String map = "philippines.map";
public CustomMapView(Context context) {
super(context);
// set context
this.context = context;
// need help here ...
AndroidGraphicFactory.createInstance(this.getApplication());
// inflate map.xml | setContentView
inflate(this.context, R.layout.map, this);
// create map layout
create();
// start map
start();
}
/**
* Create map layout
* and controls.
*/
private void create() {
this.mapView = (MapView) findViewById(R.id.mapView);
this.mapView.setClickable(true);
this.mapView.getMapScaleBar().setVisible(true);
this.mapView.setBuiltInZoomControls(true);
this.mapView.getMapZoomControls().setZoomLevelMin((byte) 10);
this.mapView.getMapZoomControls().setZoomLevelMax((byte) 20);
// create a tile cache of suitable size
this.tileCache = AndroidUtil.createTileCache(
context,
"mapcache",
mapView.getModel().displayModel.getTileSize(),
1f,
this.mapView.getModel().frameBufferModel.getOverdrawFactor()
);
}
/**
* Start map
*/
private void start() {
this.mapView.getModel().mapViewPosition.setCenter(new LatLong(14.788405, 121.069563));
this.mapView.getModel().mapViewPosition.setZoomLevel((byte) 12);
// tile renderer layer using internal render theme
MapDataStore mapDataStore = new MapFile(getMapFile());
this.tileRendererLayer = new TileRendererLayer(
tileCache,
mapDataStore,
this.mapView.getModel().mapViewPosition,
false,
true,
true,
AndroidGraphicFactory.INSTANCE
);
tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
// only once a layer is associated with a mapView the rendering starts
this.mapView.getLayerManager().getLayers().add(tileRendererLayer);
}
/**
* Get map file
*
* #return
*/
private File getMapFile() {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
// absolute path of internal Downloads folder
String dirDownloads = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
File file = new File(dirDownloads + "/" + map);
return file;
}
}
I have two action-script classes one is instantiated in the other. It works fine in flash professional cc but when I use the mxmlc compiler via the command prompt, it compiles a blank swf without any errors.
Monster.as
package {
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.display.Sprite;
import flash.display.Loader;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class Monster extends Sprite {
public function Monster() {
// constructor code
var imageLoader: Loader = new Loader();
var image: URLRequest = new URLRequest("female-monster.png");
imageLoader.load(image);
addChild(imageLoader);
imageLoader.x = 0;
imageLoader.y = 0;
}
public function roar():void {
var mySound: Sound = new Sound();
mySound.load(new URLRequest("monster.mp3"));
mySound.play();
}
public function visibleMonster():void {
this.alpha = .5;
}
}
}
addMonster.as
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import Monster;
public class addMonster extends MovieClip {
public var monster:Monster;
public function addMonster() {
// constructor code
monster = new Monster();
addChild(monster);
monster.roar();
monster.moveMonster();
monster.visibleMonster();
}
}
}
Is it possible that there are options I need to use when running the command to compile?
Solved problem by closing Dreaweaver and Flash applications which were using the file I was trying to run mxmlc compiler to compile the as file.