i always error
this my activity
public class ARActivity extends SherlockFragmentActivity {
ArchitectView arview;
#Override
protected void onCreate(Bundle arg0) {
// TODO Auto-generated method stub
super.onCreate(arg0);
setContentView(R.layout.sample_cam);
this.arview = (ArchitectView) findViewById(R.id.architectView);
final ArchitectConfig config = new ArchitectConfig(
WikitudeSDKConstants.WIKITUDE_SDK_KEY);
this.arview.onCreate(config);
}
#Override
protected void onPostCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onPostCreate(savedInstanceState);
this.arview.onPostCreate();
try {
this.arview.load("assets/wikitude/imageRecognition/index.html");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
and this my xml
and i get error
please help me :(
Please check out the Wiktiude SDK Sample App, which is part of the Wikitude SDK.
It comes with a "AbstractArchitectCamFragmentV4.java" and a "AbstractArchitectCamActivity.java", which define the required lifecycle methods properly.
I guess implementing the remaining onResume, onPause, onDestroy should solve the issue.
Kind regards,
Andreas
Related
I know there are several answers to this question, but it isn't working for me, currently my code is:
public class LogoutService extends Service {
public static CountDownTimer timer;
#Override
public void onCreate(){
// TODO Auto-generated method stub
super.onCreate();
timer = new CountDownTimer(1 * 60 * 1000, 1000) {
public void onTick(long millisUntilFinished) {
//Some code
Log.v(TAG, "Service Started");
}
public void onFinish() {
Log.v(TAG, "Call Logout by Service");
// Code for Logout
stopSelf();
}
};
}
#Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
}
and in every activity I have:
#Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
LogoutService.timer.start();
}
#Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
LogoutService.timer.cancel();
}
But I get a "Unable to resume activity java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.CountDownTimer android.os.CountDownTimer.start()' on a null object reference" when I try to start any of my activities that contain this code. My application isn't too complicated, it's completely offline, so no web service calls or anything, I just need to go back to my login activity after x minutes. Anyone have any ideas?
Here's the one I used: Auto logout after X minutes, Android and http://androidjug.blogspot.com/2015/10/auto-logout-after-15-minutes-due-to.html
You aren't starting the service, so you aren't allocating the timer. Really you should not be using a static for this.
I am trying to do an app in which there is a splash screen in the beginning. During loading, i need to show "Loading images...Loading modules....Now you are ready to go",etc. This is similar to the way in which facebook app loads showing the splash screen. I don't know how to do this. This is my current code :
public class Splash extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread logoTimer = new Thread(){
public void run(){
try{
int logoTimer = 0;
while (logoTimer<5000){
sleep(100);
logoTimer=logoTimer+100;
}
startActivity(new Intent("com.package.MAIN"));
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
finish();
}
}
};
logoTimer.start();
}
}
I would also like to keep a ProgressBar along with this. Can anyone help me out with a sample code or a reference. Thanks in advance.
You could use Handler to communicate from background thread to UI thread. Handler should send messages to UI when loading of one module is finished.
I am developing an android application and I want close the window of view adds after I click on the adds window using Resume event.I put a rule in resume event but this rule make adds never show. so if there is a way to make the view adds disappears when I return to my application?
this is my code:
#Override
protected void onResume() {
// TODO Auto-generated method stub
if (adView != null) {
adView.destroy();
}
super.onResume();
}
this is the right code:
protected void onResume() {
// TODO Auto-generated method stub
adView.setAdListener(new AdListener() {
#Override
public void onAdOpened() {
// Save app state before going to the ad overlay.
}
#Override
public void onAdClosed() {
adView.setVisibility(View.GONE);
// TODO Auto-generated method stub
super.onAdClosed();
}
});
super.onResume();
}
use following to disappear the view.
adView.setVisibility(View.GONE):
set an onClickListener on adView then in onClick call this method.
How can I write command in onclicklistener() so that I can move to next activity as well as my post status dialog will appear on that new activity. I am using intent for switching to next activity and also using postTowall() method. But these two doesn't perform simultaneously. I am using this method:
public void onClick(View v) {
// TODO Auto-generated method stub
postTowall();
Intent intent= new Intent(Frnd.this,Logout.class);
startActivity(intent);
}
private void postTowall() {
facebook.dialog(this, "feed", new DialogListener() {
#Override
public void onFacebookError(FacebookError e) {
}
#Override
public void onError(DialogError e) {
}
public void onComplete(Bundle values) {
String sh = null;
Bundle params = new Bundle();
params.putString("caption", sh);
}
public void onCancel() {
// TODO Auto-generated method stub
}
You can use thread for posting. Use asynctask and inside that post the message to face book. Or you may just write a simple thread and start it.
This asynctask link may help you. it has usage example also:
http://developer.android.com/reference/android/os/AsyncTask.html
You should set other activity to open post dialog. Send via intent a signal if it should or not...
private class Test extends AsyncTask<Void, Void, Void> {
#Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
Log.d("test", "called1");
}
#Override
protected Void doInBackground(Void... params) {
Log.d("test", "called2");
return null;
}
#Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
Log.d("test", "called3");
}
}
and output:
test:called1
Why other methods never don't called when Service work on background? If service stop, then all method calls and output:
test:called1
test:called2
test:called3
I guess you are testing on android 3.x or newer and you are simply affected by the change made to the way AsyncTask is executed.
This is how I handle this in my code to always work the same fully parallel:
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ) {
new Test().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
new Test().execute();
}
Basically change in AsyncTask appeared in Honeycomb (see Android SDK docs here in "Order of execution" section), so before that, you launch it as usual, for HC and up, use executeOnExecutor() if you do not like new behaviour (noone does, I think)