Quantcast
Channel: JetBrains Developer Community : All Content - IntelliJ IDEA Users
Viewing all 5481 articles
Browse latest View live

GCMRegistrar.getRegistrationId returns empty String

$
0
0

I have some problem to using GCM in Fragment.

first, I get example App to using GCM I try and it work fine.

so I using this example code to I use in my Application but I always getting empty string from GCMRegistrar.getRegistrationId

this is my code.

 

Controller.java

publicclass Controller extends Application{     private  finalint MAX_ATTEMPTS = 5;    private  finalint BACKOFF_MILLI_SECONDS = 2000;    private  final Random random = new Random();     static Context ct;     public Controller(Context context) {        ct = context.getApplicationContext();    }     // Register this account with the server.    publicvoid register(final Context context, String name, String email, final String regId) {         Log.i(Config.TAG, "registering device (regId = " + regId + ")");         String serverUrl = Config.YOUR_SERVER_URL;         Map<String, String> params = new HashMap<String, String>();        params.put("regId", regId);        params.put("name", name);        params.put("email", email);         ....    }     // Notifies UI to display a message.    publicvoid displayMessageOnScreen(Context context, String message) {        Intent intent = new Intent(Config.DISPLAY_MESSAGE_ACTION);        intent.putExtra(Config.EXTRA_MESSAGE, message);        context.sendBroadcast(intent);    } } 

 

Config.java

publicinterface Config {    staticfinal String YOUR_SERVER_URL =  "url Server";    staticfinal String GOOGLE_SENDER_ID = "sender id";    staticfinal String TAG = "GCM Android ";    staticfinal String DISPLAY_MESSAGE_ACTION ="com.MyApp.gcm.DISPLAY_MESSAGE";    staticfinal String EXTRA_MESSAGE = "message";               }

 

GCMIntentService.java

publicclass GCMIntentService extends GCMBaseIntentService {     privatestaticfinal String TAG = "GCMIntentService";    private Controller aController = null;    public GCMIntentService() {        super(Config.GOOGLE_SENDER_ID);    }     @Override    protectedvoid onRegistered(Context context, String registrationId) {        if(aController == null)            aController = (Controller) getApplicationContext();        Log.i(TAG, "Device registered: regId = " + registrationId);        aController.displayMessageOnScreen(context, "Your device registred with GCM");        aController.register(context, ProfileFragment.name, ProfileFragment.email, registrationId);    }     @Override    protectedvoid onUnregistered(Context context, String registrationId) {        if(aController == null)            aController = (Controller) getApplicationContext();        Log.i(TAG, "Device unregistered");        aController.displayMessageOnScreen(context, getString(R.string.gcm_unregistered));        aController.unregister(context, registrationId);    }     @Override    protectedvoid onMessage(Context context, Intent intent) {        if(aController == null)            aController = (Controller) getApplicationContext();        Log.i(TAG, "Received message");        String message = intent.getExtras().getString("price");        aController.displayMessageOnScreen(context, message);        generateNotification(context, message);    }     @Override    protectedvoid onDeletedMessages(Context context, int total) {        if(aController == null)            aController = (Controller) getApplicationContext();        Log.i(TAG, "Received deleted messages notification");        String message = getString(R.string.gcm_deleted, total);        aController.displayMessageOnScreen(context, message);        generateNotification(context, message);    }     @Override    publicvoid onError(Context context, String errorId) {        if(aController == null)            aController = (Controller) getApplicationContext();        Log.i(TAG, "Received error: " + errorId);        aController.displayMessageOnScreen(context, getString(R.string.gcm_error, errorId));    }     @Override    protectedboolean onRecoverableError(Context context, String errorId) {        if(aController == null)            aController = (Controller) getApplicationContext();        Log.i(TAG, "Received recoverable error: " + errorId);        aController.displayMessageOnScreen(context, getString(R.string.gcm_recoverable_error, errorId));        return super.onRecoverableError(context, errorId);    }     privatestaticvoid generateNotification(Context context, String message) {        int icon = R.drawable.ic;        long when = System.currentTimeMillis();        NotificationManager notificationManager = (NotificationManager)                context.getSystemService(Context.NOTIFICATION_SERVICE);        Notification notification = new Notification(icon, message, when);        String title = context.getString(R.string.app_name);        Intent notificationIntent = new Intent(context, ProfileFragment.class);        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |                Intent.FLAG_ACTIVITY_SINGLE_TOP);        PendingIntent intent =                PendingIntent.getActivity(context, 0, notificationIntent, 0);        notification.setLatestEventInfo(context, title, message, intent);        notification.flags |= Notification.FLAG_AUTO_CANCEL;        notification.defaults |= Notification.DEFAULT_SOUND;        notification.defaults |= Notification.DEFAULT_VIBRATE;        notificationManager.notify(0, notification);    }}

 

 

AndroidManifest.xml

<permission            android:name="com.MyApp.permission.C2D_MESSAGE"            android:protectionLevel="signature" />    <uses-permission android:name="android.permission.INTERNET"/>    <uses-permission android:name="android.permission.GET_ACCOUNTS" />    <uses-permission android:name="android.permission.WAKE_LOCK"/>    <uses-permission android:name="com.MyApp.permission.C2D_MESSAGE" />    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>    <uses-permission android:name="android.permission.VIBRATE"/>    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/><application            android:allowBackup="true"            android:icon="@drawable/ic"            android:label="@string/app_name"            android:theme="@style/AppTheme">        <activity                .....            <intent-filter>                <action android:name="android.intent.action.VIEW"/>                <action android:name="android.intent.action.DELETE"/>                <category android:name="android.intent.category.DEFAULT"/>            </intent-filter>        </activity>        <receiver                android:name="com.google.android.gcm.GCMBroadcastReceiver"                android:permission="com.google.android.c2dm.permission.SEND" >            <intent-filter>                <action android:name="com.google.android.c2dm.intent.RECEIVE" />                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />                <category android:name="com.MyApp" />            </intent-filter>        </receiver>        <service android:name=".gcm.GCMIntentService" android:enabled="true"/>    </application>

 

LoginFragment.java

        GCMRegistrar.checkDevice(getActivity());        GCMRegistrar.checkManifest(getActivity());        final String regaId = GCMRegistrar.getRegistrationId(getActivity().getApplicationContext());        if (regaId.equals("")) {            GCMRegistrar.register(getActivity(), Config.GOOGLE_SENDER_ID);        }else{             .....        }

 

 

please help me..


Where does IntelliJ send auth data from App "Register" ?

$
0
0

Good morning,

 

We've been having an issue authenticating from behind our firewall with Jetbrains server while Registering.

 

When we submit the request, we get the following:

 

JetProfile connection error: SSLHandshakeException: java.security.cert.CertificateException: java.security.SignatureException: Signature length not correct: got 256 but was expecting 512.

 

I know that our network replaces certs as they come in - so I asked our networking team to make an exception for:

 

https://lservice-auth.jetbrains.com

 

After the change, when I check the cert in a browser it is the same behind our firewall as not behind our firewall, yet we continue to have this issue with Registration.

 

Is there a different domain with which the Registration request is communicating?  Do we need another exception?

 

Please advise -

 

Thanks,

 

Matty

Persist User Data on a Virtual File

$
0
0

I need to know when a filre has changed while IntelliJ was down. I use a UserData on the Virtual File but that is not restored after a restart. Then I tried to use the BulkFileListener but I don't receive an update during the initial refresh.

 

So is there a way to psersist user data on a virtual file so that I can detect a change when IntelliJ / Plugin is restarted? Or is there a way to discover changes on a file when the IntelliJ is restarted?

 

- Andy

How do you include environment variables in params for run configurations?

$
0
0

Hello,

 

I'm using nosetests to set some variables before running my tests and at work we're using a makefile. I'd like to debug these tests and have been using the params option in Intellij to set relevant environment vairables however I can't seem to use said environment variables in the params as you can see in the illustration below.

Snip20150604_4.png

 

As you can see when I set a test config variable manually (i.e. --tc=foo.bar:foo-bar) the variable shows up in the watches, however, using an environment variable simply shows a dollar sign with the name.

Any help is much appreciated

Why aren't typescript files compiled on "make"

$
0
0

I have installed the typescript plugin in IntelliJ 14.1.3.

When I double-click on a typescript file, the .js file and the .map file are generated as they should, but when I run "make" they are not generated. This is an issue because those generated files are not tracked by my VCS so I have to double-click every TS file in the project.

 

Is there a way to have "make" build typescript files?

Creating a Gradle Project

$
0
0

Hello,


I'm new to IntelliJ and Gradle, so am trying to follow the "Creating a Gradle Project" here: https://www.jetbrains.com/idea/help/creating-a-gradle-project.html.

 

My current env:

Window s8.1

Gradle 2.4

JDK 1.8.0_45

IntelliJ IDEA 14.1.3

 

I have Gradle 2.4 installed with GRADLE_HOME defined and the gradle bin directory added to my path.  I can call the gradle executable from a cmd prompt.  So, I choose "Create New Project" from the IntelliJ start screen, then choose "Gradle" in the left column.  I then specify the JDK version in the Project SDK: drop down.  This is where the directions break down; there are no Gradle settings to specify.  Clicking next takes me to a wizard page asking for GroupId, ArtifactId and Version.  Not sure what to put here or where to go from here!


Thanks!
Darren

js debug doesn't work

$
0
0

I did js configuration. In the url field I selected the index.jsp file from my file system. So in url I see 

http://localhost:7001/somepath/index.jsp. The somepath differs from from path to index.jsp on my file system. So I am starting js debug and getting 'not found'. How to switch js debug?

Make maven projects

$
0
0

Just trying to switch from Eclipse to IntelliJIdea. My projects are always maven based. So one issue that I'm facing right now - I opened a maven project with compilation issues. Fixed the pom.xml however the problems view is showing compilation issues, but my maven compile completes successfully. I tried rebuilding the project, Make the project - They both fail with the original compilation issue of package name not found. However running maven build from the tool window complete successfully. The problems view is still showing the same original compilation problems. Any help to solve this puzzle will be appreciated.


how to set working dir when launch tomcat

$
0
0

hi folks

 

as i know when launch java application in intellij, can specify the working dir.

so now i'd like to launch a web application with tomcat server, but not found a way to specify the working dir, could you give me some hint?

thanks

How do you change the set of file types listed for new scratch files?

$
0
0

I work in ColdFusion a lot, and neither CFC nor CFM file types are available. There are also some types I might remove if I could, because I'm unlikely to use them.

 

Is this something we can control?

 

Thanks.

Groovy template edition

$
0
0

Hi, evryone!

 

Who knows how to edit groovy extract variable template, I want to set default behavior autoinsert variable type instead of 'def' ?

 

Best regards, N. Mikhailov!

Syntax highlighting for FeatureSpec Scalatest

$
0
0

Hi,

 

 

While FunSpec gets a bit of syntax coloring for the function "it" there is nothing for highlited in featureSpec. For instance Scenario, Feature, Given When Then. I am wondering if something is not working, if the plugin never intented it, and most importantly, how can i define a syntax highlighting myself if it is possible and not too complicate to do so. I would like to give some color to those key function.

 

 

Please any help,

 

Maatari

How to add angularJs support to existing project (maven, war)

$
0
0

I have an empty maven/war project and want to angularjs support. how to do this? (i installed nodjs and anguarjs plugin already)

 

what are the pros and cons between the 3 documented ways to get angular (manuall, npm/bower, intellij)?

Auto Import After Find/Replace

$
0
0

I have about 70 entity classes.  I used regex replace to add an annotation to every getter in every entity class.  How do I tell IDEA to import the annotation's class without opening every file (which seems to be the only way).

 

What I've tried:

  1. Clicking the package --> Code --> Optimize Imports
  2. Clicking the package --> Code --> Reformat Code (incidentially this does successfully properly indent the newly added annotations)
  3. Selecting all classes in the package --> Code --> Optimize Imports
  4. Selecting all classes in the package --> Code --> Reformat Code
  5. Invalidate Caches and Restart
  6. Synchronize

 

Thanks.

Error Setting up Oracle Weblogic 10.6 in Idea Ultimate 14.1.2.

$
0
0

I've purchased a licensed version of Idea but I'm unable to set up Oracle Weblogic 10.6 in Idea Ultimate 14.1.2( It's saying "Selected directory is not a valid weblogic Home" ). I've my MW_HOME setup C:\Oracle\Middleware\wlserver_10.3 which is where my WLS is.

How do I get this fixed quickly? It's not Weblogic 12C or anything,


How to find obsolete HTML tags and attributes

$
0
0

I'm looking for a way for IntelliJ IDEA to show me elements of HTML and JSP pages that are obsolete in HTML 5.  Ideally, I seem to remember a code inspection doing this for me in a prior version of IDEA, but it doesn't seem to be working in version 14.  I did find the "Deprecated HTML tag" inspection, and it is enabled, but nothing is being highlighted in my HTML pages.

 

Is there an inspection or setting that I'm missing?

 

Thanks in advance,

 

Steve Saliman

Java 8 JRE javadoc for offline

$
0
0

How can I install JRE 8 javadocs for offline use in Intellij? I tried the obvious solution of downloading the docs from here

 

   http://www.oracle.com/technetwork/java/javase/documentation/jdk8-doc-downloads-2133158.html

 

and then point IntelliJ to the zip file under the "Documentation Paths" tab of the SDKs settings. No dice.

 

Since I have offline for most other libraries (downloaded autmatically through maven), I figure I should be able to get the offline docs for the JRE too somehow. Note that I can use the onlinedocs by entering the URL in the"Documentation Paths" tab. But I would prefer to have the docs for offline use so I can at get it any time,

 

-JM

Importing spring project

$
0
0

Hey,

 

I'm using tutorial https://spring.io/guides/gs/rest-service/

 

To learn about spring. When I imported the project I'm getting the Cannot resolve symbol @RestController

 

The import is:

import org.springframework.web.bind.annotation.RestController;

I added framework support, which downloaded the sptring libs.

However Alt + Enter does not give me the right import from the downloaded libs.

What is the correct way to import it?

[request] add support to run multi testng suite xml

$
0
0

HI folks

 

in our case, we want to run multi testng suite xml in an ordered manner.

 

for now, in the run configuration of testng, when select the "Suite" radio button, only one suite.xml can be set.

 

see also, testng eclipse plugin does support this feature.

how to set working dir when launch tomcat

$
0
0

hi folks

 

as i know when launch java application in intellij, can specify the working dir.

so now i'd like to launch a web application with tomcat server, but not found a way to specify the working dir, could you give me some hint?

thanks

Viewing all 5481 articles
Browse latest View live